您的位置:首页 > 移动开发 > Android开发

Android布局的小窍门?

2012-07-18 21:26 1306 查看

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

我要实现如下的效果:

我只想用一个RelativeLayout来实现,不想嵌套,因为xml嵌套的越多我们的程序的效率越低…解析xml多一层就慢了不少…最苦逼的是又下角的素材全透明而且很小很小…妹的…
这样我就没办法调整图片和父控件底部的距离了有木有…


但是我想到了一个更加苦逼的办法…
我在这下面又加了一个TextView来占地方…让这个TextView宽度fill_parent,高度wrap_content…
不给他设置内容…因为TextView默认背景是透明的…所以达到了想要的效果…

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#f9f5f2" >

<TextView
android:id="@+id/xinwen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dip"
android:layout_marginLeft="10dip"
android:layout_marginTop="6dip"
android:text="全球新闻"
android:textSize="16dip" />

<TextView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/xinwen"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:text="国际在线
专稿:据英国《每日电 讯报》7月16日报道,法国社会党政府即将执行的增税计划迫使大批富豪变卖家财,逃往“对富人友好的国家”,比如英国和瑞士等。"
android:textSize="11dip" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/salonbookicon"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:paddingBottom="3dip"
android:text="2012年12月12日"
android:textColor="#fb4b4d"
android:textSize="10dip" />

<ImageView
android:id="@+id/salonbookicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/header"
android:layout_marginRight="14dip"
android:layout_marginTop="15dip"
android:background="@drawable/read_more" />

<TextView
android:layout_below="@+id/salonbookicon"
android:layout_width="fill_parent"
android:textSize="7dip"
android:layout_height="wrap_content" />

</RelativeLayout>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  布局