3
我想將邊框設置爲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時只使用背景色改變了但邊界保持不變)。