標籤:android c style class blog code
今天寫組件的時候用到了描邊。可是兩個組件放在一起時,描邊會變重疊,使之變粗。就不是很美觀了。
如何取消呢?網上查了好久沒找到,然後就自己試了試,找到瞭解決方法,就在此記錄一下,防止以後忘記。
很簡單分別給兩個控制項添加 android:layout_marginRight="-1dp"和android:layout_marginLeft="-1dp"
這裡面的值要設定成-1。否則是沒有效果的。設定後的效果:
布局檔案如下。
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="horizontal" > 6 <EditText 7 android:id="@+id/myet" 8 android:layout_weight="4" 9 android:layout_width="0dip"10 android:layout_height="50dp"11 android:ems="10"12 android:background="@drawable/border_text_selector"13 android:layout_marginRight="-1dp"14 android:singleLine="true"15 >16 </EditText>17 <ImageView18 android:id="@+id/myiv"19 android:layout_weight="1"20 android:layout_width="0dp"21 android:layout_height="50dp"22 android:background="@drawable/bg_border"23 android:layout_marginLeft="-1dp"24 android:src="@drawable/ic_launcher" />25 </LinearLayout>