2016-01-03 210 views

回答

0

最簡單的方法就是你設置的背景,活動,創造Buttons,希望你沒事的那部分,

然後你就可以使用android:alpha=""屬性中的每個按鈕,使之更加透明或不透明,它可以具有從01.0的值

0

您可以在XML文件中使用TableLayout來使它們全部對齊。使用weight屬性給他們的大小,選擇一個不透明的背景color.I用下面的代碼在一個相對佈局和它來八九不離十:

<TableLayout 
    android:layout_alignParentBottom="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TableRow 
     android:gravity="center_horizontal"> 
     <Button 
      android:text="Button" //Store this in your strings resource folder 
      android:background="#a6000000" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      android:layout_height="150dp"//Store this in your dimens resource folder/> 
     <Button 
      android:text="Button" 
      android:layout_weight="1" 
      android:background="#a6000000" 
      android:layout_width="wrap_content" 
      android:layout_height="150dp" 
      android:layout_marginLeft="10dp"/> 
    </TableRow> 

    <TableRow 
     android:layout_marginTop="10dp" 
     android:gravity="center_horizontal"> 
     <Button 
      android:text="Button" 
      android:layout_weight="1" 
      android:background="#a6000000" 
      android:layout_width="wrap_content" 
      android:layout_height="150dp"/> 
     <Button 
      android:text="Button" 
      android:layout_weight="1" 
      android:background="#a6000000" 
      android:layout_width="wrap_content" 
      android:layout_height="150dp" 
      android:layout_marginLeft="10dp"/> 
    </TableRow> 

</TableLayout> 
0

,只要你想我上面已經創建的佈局。請參考下面的XML。 希望它有幫助!

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:orientation="vertical" 
android:weightSum="5" 
android:alpha="0.5" 
android:background="@drawable/backround" 
android:layout_height="match_parent" 
tools:context=".MainActivity"> 
<LinearLayout 
android:alpha="0.5" 
android:layout_width="match_parent" 
android:layout_weight="3" 
android:layout_height="0dp"> 
<!--Put your any content here--> 
</LinearLayout> 

<LinearLayout 
android:alpha="0.5" 
android:layout_weight="2" 
android:weightSum="2" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="0dp"> 
<LinearLayout 

android:layout_weight="1" 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="0dp"> 
<Button 
android:layout_weight="1" 
android:layout_width="0dp" 
android:layout_height="match_parent" /> 
<Button 
android:layout_weight="1" 
android:layout_width="0dp" 
android:layout_height="match_parent" /> 
</LinearLayout> 
<LinearLayout 
android:layout_weight="1" 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="0dp"> 
<Button 
android:layout_weight="1" 
android:layout_width="0dp" 
android:layout_height="match_parent" /> 
<Button 
android:layout_weight="1" 
android:layout_width="0dp" 
android:layout_height="match_parent" /> 
</LinearLayout> 
</LinearLayout> 
</LinearLayout>