zoukankan      html  css  js  c++  java
  • android 入门-Activity及 字体

        private Button sButton;
        private TextView mTextView;
        private Button fButton;
        private int[] sArray={13,25,38,34,42};
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_ex0313);
            
            mTextView=(TextView)findViewById(id.Ex0313DisplayText);
            sButton=(Button)findViewById(id.Ex0313SizeButton);
            sButton.setOnClickListener(new Button.OnClickListener() {
                
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    
                    Random mRandom=new Random();
                    int mNum = mRandom.nextInt(4);
                    mTextView.setTextSize(sArray[mNum]);
                }
            });        
            
            fButton=(Button)findViewById(id.Ex0313FontsButton);
            fButton.setOnClickListener(new Button.OnClickListener() {
                
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Typeface fTypeface=Typeface.createFromAsset(getResources().getAssets(),"fonts/PentaGram'sMalefissent.ttf");
                    mTextView.setTypeface(fTypeface);
                }
            });                
        }

         <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Ex0313DisplayText"
         android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp"        
            android:text="@string/hello_world" />
    <Button android:id="@+id/Ex0313SizeButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="50dp"
            android:text="@string/ex0313sizebutton" />
    <Button android:id="@+id/Ex0313FontsButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="100dp"
            android:text="@string/ex0313fontsbutton" />
  • 相关阅读:
    通向全栈之路——(4)nginx反向代理配置
    通向全栈之路——(3)node环境搭建
    通向全栈之路——(2)服务器安全设置
    通向全栈之路——(1)服务器新增用户及授权
    window.location.href跳转至空白页
    webpack 1.x 学习总结
    win7下使用apache ab 比较测试node与 tomcat
    Enum,Int,String的互相转换
    读写appSettings配置节方法
    SC命令
  • 原文地址:https://www.cnblogs.com/androllen/p/4156137.html
Copyright © 2011-2022 走看看