千本摩的 2015-06-01 02:39 采纳率: 66.7%
浏览 1564

如何最简单实现这种结构

图片说明

 <RelativeLayout
        android:id="@+id/btn_alipay"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:background="@drawable/btn_line_green"
        android:layout_width="match_parent"
        android:layout_height="40dp">
        <LinearLayout
            android:duplicateParentState="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="20dp">
            <ImageView
                android:duplicateParentState="true"
                android:src="@drawable/ic_alipay"
                android:scaleType="fitXY"
                android:adjustViewBounds="true"
                android:layout_width="wrap_content"
                android:layout_height="20dp" />
            <TextView
                android:duplicateParentState="true"
                android:layout_marginLeft="3dp"
                android:text="使用支付宝充值"
                android:gravity="center"
                style="@style/TextView_Small_Green"
                android:textColor="@drawable/buyue_green_all"
                android:layout_width="wrap_content"
                android:layout_height="20dp" />
        </LinearLayout>
    </RelativeLayout>

android studio 提示
This 'LinearLayout' layout or its 'RelativeLayout' parent is useless; transfer the 'background' attribute to the other view (at line 37)

  • 写回答

1条回答 默认 最新

  • danielinbiti 2015-06-01 02:47
    关注

    布局本身没问题,不过可以去掉linearlayout,imageview和textview可以用android:layout_toRightOf或者android:layout_toLeftOf的方式进行布局。
    背景图片可以用9patch处理一下,把文字位置可以直接标出来。

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题