Android 基础标签

    TextView标签

<TextView
            android:text="我乃哈哈哈哈哈哈哈学习Androd"
            android:textSize="25dp"
            android:textColor="@android:color/holo_blue_dark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            />

text:显示文本信息
textSize:设置文本大小
textColor:设置文本颜色
singleLine:单行显示
ellipsize:设置省略号显示的位置,默认是end(结尾) start(开头) middle(中间)

 

<TextView
            android:text="哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈啊哈哈哈哈哈哈"
            android:textSize="25dp"
            android:textColor="@android:color/holo_blue_dark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="1"

            />

android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit  循环滚动次数(属性值marquee_forever代表一直滚动)
android:marqueeRepeatLimit="5"

enabled:设置按钮是否可以点击
drawableTop:在按钮文字上方加入图片
drawableBottom
drawableLeft
drawableRight
drawableStart:国际化标准左
drawableEnd:国际化标准右

  <TextView
                     android:text="QQ邮箱: 1344773678@qq.com    电话: 15116964938   网站:  www.baidu.com"
                     android:textSize="25dp"
                     android:textColor="@android:color/holo_blue_dark"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:autoLink="all"

                     />
   

                     <Button
                         android:text="这只是个按钮"
                         android:textColor="@android:color/holo_green_light"
                         android:textSize="30dp"
                         android:enabled="false"
                         android:drawableTop="@mipmap/ic_launcher"
                         android:drawableRight="@mipmap/ic_launcher"
                         android:drawableLeft="@mipmap/ic_launcher"
                         android:drawableBottom="@mipmap/ic_launcher"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         />


               <Button
                   android:text="er"
                   android:id="@+id/but01"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content" />

               <Button
                   android:text="san"
                   android:id="@+id/but02"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content" />

                 <TextView
                     android:id="@+id/tvshow"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content" />
         

代码

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_textview);

        View.OnClickListener click = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int id = v.getId();
                switch (id) {
                    case R.id.but01:
                        tvshow = (TextView) findViewById(R.id.tvshow);
                        tvshow.setText("我来啦一号");
                        break;
                    case R.id.but02:
                        tvshow = (TextView) findViewById(R.id.tvshow);
                        tvshow.setText("我来啦二号");
                        break;
                }

            }
        };

        Button button = (Button) findViewById(R.id.but02);
        Button button2 = (Button) findViewById(R.id.but01);
        button.setOnClickListener(click);
        button2.setOnClickListener(click);

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

原文地址:https://www.cnblogs.com/xuhaifeng017/p/8252778.html