android 控制項描邊取消重疊

來源:互聯網
上載者:User

標籤: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>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.