2017-05-09 37 views
0

最近,我公司的設計人員喜歡在Android應用程序的佈局中創建半個以上的元素。我一直在努力嘗試讓這些元素儘可能地表現出色,但我已經厭倦了它。有沒有這個圖像在佈局上方定位圖標

Layout 上定位的看法就像一個假設,如果用戶觸摸行/卡成了「檢查」,這黑點圖標變得可見(第二次點擊使其不可見當然)的任何方式。

回答

1

你可以做這樣的事情:

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toEndOf="@+id/circle_view" 
     android:background="@android:color/holo_blue_bright"> 

     <android.support.v7.widget.CardView 
      android:id="@+id/second_view" 
      android:layout_width="100dp" 
      android:layout_height="match_parent"/> 

    </FrameLayout 

    <View 
     android:id="@+id/circle_view" 
     android:layout_width="16dp" 
     android:layout_height="16dp" 
     android:background="@android:color/holo_red_dark" 
     android:layout_marginEnd="-8dp" 
     android:layout_centerVertical="true"/> 

</RelativeLayout> 

second_view是endOf circle_view所以如果circle_view走了second_view將調整到STARTOF父。

circle_view應該有marginEnd設置爲劃分其寬度負值由兩個

enter image description here

+0

但我需要「second_view」總是充分的可用空間,我不能只讓100dp寬度。 –

+0

因此將second_view的寬度設置爲match_parent :)我只爲測試設置了100dp。我添加了它在編輯器 –

+0

看起來很喜歡的截圖:) –