用Drawable来实现UI元素的间隔
来源:互联网 发布:java基础知识点汇总 编辑:程序博客网 时间:2024/05/16 19:34
一、在LinearLayout里面设置3个Button
<LinearLayout android:id="@+id/buttons_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/btn_first" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_weight="1" android:background="#903212" android:text="button_1" /> <Button android:id="@+id/btn_second" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:layout_weight="1" android:background="#435283" android:text="button_2" /> <Button android:id="@+id/btn_third" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#648205" android:text="button_3" /> </LinearLayout>
效果图为:
二、将Button3的visibility属性设置为gone,效果为
可以看出Button2的右边有间距,需要实现的是Button2右边紧挨屏幕
三、通过Linearlayout的divider属性来实现
在drawable目录下创建spacer_mudium.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <size android:width="10dp" android:height="10dp" /> <solid android:color="@android:color/transparent" /></shape>
在LinearLayout设置showDividers和divider属性
需要注意的:LinearLayout的divider属性是API 11 才加入的,如果要在低版本使用divider属性则需要用LinearLayoutCompat.
0 0
- 用Drawable来实现UI元素的间隔
- Android UI——使用Drawable来实现扁平化的按钮
- 巧用Drawable 实现Android UI 元素间距效果
- 巧用Drawable 实现Android UI 元素间距效果
- 巧用Drawable 实现Android UI 元素间距效果
- 巧用Drawable 实现Android UI 元素间距效果
- 巧用Drawable 实现Android UI 元素间距效果
- 用DIV 来代替JAVASCRIPT以实现无间隔新闻滚动的效果
- 不用Drawable来实现Imageview的点击效果
- CEF的C#实现,可以实现用Chrome来渲染UI,期待已久的UI解决方案。
- CEF的C#实现,可以实现用Chrome来渲染UI,期待已久的UI解决方案。
- Drawable转BitMap实现Drawable的缩放
- 日期-时间间隔的实现
- Drawable 下定义一个会旋转的ui
- 用C实现计算时间间隔的方法
- 用html来设计应用程序的UI
- 尝试用图像处理来实现UI设计稿的自动标注
- 利用Canvas 的 scale来反转 drawable
- git 整理
- no lable views point to this text field with an android:lablFor=”@+id/@+id
- SAP 常用T-CODE
- android 4G产品4G网络问题记录
- activeMQ networkConnectors
- 用Drawable来实现UI元素的间隔
- Smali和逆向分析
- Contains Duplicate
- C++里的继承和多态(中)——分析单继承、多继承、菱形继承(不含虚函数)
- 设计模式(7)之装饰模式
- 腾讯2016实习生招聘后台研发面试经
- 清空cookie
- CocoaPods的使用,简便方法
- C++第4次实验(提高班)—继承和派生1