第37篇 Android Studio实现点击图片显示信息(四)布局及资源文件

第37篇 Android Studio实现点击图片显示信息(四)布局及资源文件

4.布局文件

整体是一个垂直布局,然后在设置一些水平布局就行了。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/dormitory_information"
        android:textSize="25sp"
        />

    <RadioGroup
        android:id="@+id/rgp_one"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/rbt_student1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student_name_zhao"
            android:background="@drawable/radiobutton_background_style"/>
        <RadioButton
            android:id="@+id/rbt_student2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:button="@null"
            android:gravity="center"
            android:layout_weight="1"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student_name_wu"
            android:background="@drawable/radiobutton_background_style"/>
        <RadioButton
            android:id="@+id/rbt_student3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student_name_gong"
            android:background="@drawable/radiobutton_background_style"/>
    </RadioGroup>

    <RadioGroup
        android:id="@+id/rgp_two"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/rbt_student4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student_name_chen"
            android:background="@drawable/radiobutton_background_style"/>
        <RadioButton
            android:id="@+id/rbt_student5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student"
            android:background="@drawable/radiobutton_background_style"/>
        <RadioButton
            android:id="@+id/rbt_student6"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:button="@null"
            android:layout_weight="1"
            android:gravity="center"
            android:drawableTop="@mipmap/background_player2"
            android:text="@string/student"
            android:background="@drawable/radiobutton_background_style"/>
    </RadioGroup>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginTop="30dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_information"
            android:textSize="20sp"/>
        <TextView
            android:id="@+id/txt_student_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_name"/>
        <TextView
            android:id="@+id/txt_student_sex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_sex"/>
        <TextView
            android:id="@+id/txt_student_ban"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_ban"/>
        <TextView
            android:id="@+id/txt_student_dormitory"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_dormitory"/>
        <TextView
            android:id="@+id/txt_student_bed"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_bed"/>
        <TextView
            android:id="@+id/txt_student_class"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/student_class"/>
    </LinearLayout>

</LinearLayout>

我比较喜欢用LinearLyout布局,这个比较熟,而且自适应也比较好,所以用这个比较好。

4.1.strings.xml

<resources>
    <string name="app_name">宿舍人员信息</string>
    <string name="dormitory_information">宿舍人员名单</string>
    <string name="student_name_zhao">张三</string>
    <string name="student_name_wu">李四</string>
    <string name="student_name_gong">王五</string>
    <string name="student_name_chen">杨六</string>
    <string name="student">学生</string>
    <string name="student_information">学生信息</string>
    <string name="student_name">姓名: </string>
    <string name="student_sex">性别: </string>
    <string name="student_ban">楼栋: </string>
    <string name="student_dormitory">宿舍: </string>
    <string name="student_bed">床号: </string>
    <string name="student_class">班级: </string>

    <string name="sex_man"></string>
    <string name="ban_number">6栋</string>
    <string name="dormitory_number">506</string>
    <string name="bed_number_1">1号</string>
    <string name="bed_number_2">2号</string>
    <string name="bed_number_3">3号</string>
    <string name="bed_number_4">4号</string>
    <string name="class_name">软工1903</string>

    <string name="no_student">未添加</string>
</resources>
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大唐不良猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值