android中典型的LinearLayout

android中典型的LinearLayout

1的实现:给中间组件设置权重android:layout_weight="1"

2的实现:给每个组件设置权重为1和高度为“fill_parent”或“match_parent-à

android:layout_height="match_parent"

        android:layout_weight="1"

3带有背景图片的文本框的实现:

这两个文本框实则是两个LinearLayout,里面分别内嵌了<TextView>,<EditText>,<ImageButton>

1LinearLayout给它的背景设置为:android:background="@android:drawable/edit_text"

2EditText的背景何权重设置为:

android:layout_weight="1" android:background="@null"

3ImageButton的样式和图片设置为:style="@android:style/Widget.Button.Inset"

android:src="@android:drawable/star_big_on"

  具体实现代码如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:orientation="vertical" >

 

    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:addStatesFromChildren="true"

        android:background="@android:drawable/edit_text"

        android:gravity="center_vertical"

        android:paddingRight="0dip" >

 

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="From:"

            android:textAppearance="?android:attr/textAppearanceLargeInverse"

            android:textColor="?android:attr/textColorSecondary" />

 

        <EditText

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:background="@null"

            android:singleLine="true" />

 

        <ImageButton

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginBottom="2dip"

            android:layout_marginRight="2dip"

            android:layout_marginTop="2dip"

            android:padding="10dip"

            style="@android:style/Widget.Button.Inset"

            android:src="@android:drawable/star_big_on" />

    </LinearLayout>

 

    <LinearLayout

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:addStatesFromChildren="true"

        android:background="@android:drawable/edit_text"

        android:gravity="center_vertical"

        android:orientation="horizontal"

        android:paddingRight="0dip" >

 

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="To:"

            android:textAppearance="?android:attr/textAppearanceLargeInverse"

            android:textColor="?android:attr/textColorSecondary" />

 

        <EditText

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:background="@null"

            android:singleLine="true" />

 

        <ImageView

            style="@android:style/Widget.Button.Inset"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginBottom="2dip"

            android:layout_marginRight="2dip"

            android:layout_marginTop="2dip"

            android:padding="10dip"

            android:src="@android:drawable/star_big_on" />

    </LinearLayout>

 

</LinearLayout>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值