android的图片添加、滚动条、单选框、多选框、跳转界面

来源:互联网 发布:呼死你软件横行 编辑:程序博客网 时间:2024/05/21 06:37

1、图片的添加用ImageView控件:用android:background;方法添加就是改变他的背景,或者;android:src添加图片.
2、滚动条:用ScrollView :android:scrollbars="vertical"(垂直滚动条),一直让它显示的的属性是:android:fadeScrollbars="false";
    android:scrollbarThumbVertical设置它的颜色。
    注意一点就是:滚动条里面只能有一个子类,意思就是覆盖它的只能用一个布局去填充,
    如: <ScrollView
             xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:scrollbarThumbVertical="@android:color/holo_orange_dark"
             android:scrollbars="vertical"
             android:fadeScrollbars="false"
             android:scrollbarSize="4dp"    >

       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@android:color/holo_blue_light"
        android:orientation="vertical" >
        .
        .只能在这里面添加各种控件布局,
         . 否则会有错误报告:ScrollView  can  host  only  one   direct   chaild
        .
        .
        .              
      </LinearLayout>
   </ScrollView>

3、单选框:用<radiobutton/>来定义,但是这样一旦选择了一个,选另一个就不会的话,显示两个都选中。所以要放在RodioGrop里面;
   如:<RodioGrop    >
          <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="男" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女" />
     </RodioGrop>
        打印出来的结果是:   O  男   O 女
这样使用才会正常.


4、多选框:用chechBox来定义:
      <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="抢地主" />

         打印出来的结果是 :    □  抢地主

 

 

0 0