我想为relativelayout设置一个边框.我使relativelayout可点击并使用选择器来更改所选颜色,我也使用形状来舍入布局的角落.但是,当我选择layou时,形状将包括所有背景,包括边框.我找不到解决这个问题的方法.
这是我的main.xml
<relativeLayout androID:ID="@+ID/map_refresh" androID:layout_height="fill_parent" androID:layout_wIDth="wrap_content" androID:background="@drawable/settings_selector_up" androID:padding="15dp" androID:layout_marginleft="15dip" androID:layout_marginRight="15dip" androID:layout_margintop="5dip"> <TextVIEw androID:ID="@+ID/Text1" androID:layout_height="wrap_content" androID:layout_wIDth="wrap_content" androID:text="Map refresh period"> </TextVIEw> <TextVIEw androID:ID="@+ID/TextVIEw09" androID:layout_height="wrap_content" androID:layout_wIDth="wrap_content" androID:text="1 min" androID:layout_alignParentRight="true" androID:paddingRight="5dp"> </TextVIEw> </relativeLayout></linearLayout>
这是我的settings_selector_up.xml
<selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <!-- Non focused states --> <item androID:state_focused="false" androID:state_selected="false" androID:state_pressed="false" androID:background="@drawable/settings_border_roundup" /> <item androID:state_focused="false" androID:state_selected="true" androID:state_pressed="false" androID:drawable="@drawable/settings_border_roundup" /> <!-- Focused states --> <item androID:state_focused="true" androID:state_selected="false" androID:state_pressed="false" androID:drawable="@drawable/settings_border_roundup" /> <item androID:state_focused="true" androID:state_selected="true" androID:state_pressed="false" androID:drawable="@drawable/settings_border_roundup" /> <!-- pressed --> <item androID:state_selected="true" androID:state_pressed="true" androID:drawable="@drawable/selector_pressed" > </item> <item androID:state_pressed="true" androID:drawable="@drawable/List_selector_pressed" /></selector>
这是我的selector_pressed
<shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="rectangle"> <solID androID:color="#E6E6E6"></solID> <corners androID:radius ="10dp" /></shape>
是否有一种方法可以获得相同的结果,例如使用ListVIEw中的Listselector(在ListvIEw中,当我选择Listitem时,只有背景颜色发生了变化,但边框保持不变).
解决方法:
将整个事物放在另一个处理边框绘制的父布局中,如下所示:
<FrameLayout androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:background="your background 9-patch or shape of the border" androID:padding="some padding value so the border looks ok"> < Your relativeLayout without the border stuff ></FrameLayout>
总结 以上是内存溢出为你收集整理的android – 如何设置边框布局全部内容,希望文章能够帮你解决android – 如何设置边框布局所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)