Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android应用程序上的按钮布局_Android_Android Layout - Fatal编程技术网

Android应用程序上的按钮布局

Android应用程序上的按钮布局,android,android-layout,Android,Android Layout,谁能帮我拿一下这些钮扣吗?我想让它们看起来像照片中的四个,但我不知道怎么做 我使用的是Android Studio。简单的方法是设置活动的背景,并创建按钮,希望您对这部分没意见 然后您可以在每个按钮中使用android:alpha=”“属性使其更透明或不透明,它的值可以从0到1.0您可以在XML文件中使用TableLayout使它们对齐。使用“权重”属性为它们指定大小并选择不透明的背景色。我在相对布局中使用了以下代码,结果非常接近: <TableLayout androi

谁能帮我拿一下这些钮扣吗?我想让它们看起来像照片中的四个,但我不知道怎么做


我使用的是Android Studio。

简单的方法是设置活动的背景,并创建
按钮,希望您对这部分没意见


然后您可以在每个按钮中使用
android:alpha=”“
属性使其更透明或不透明,它的值可以从
0
1.0
您可以在XML文件中使用TableLayout使它们对齐。使用“权重”属性为它们指定大小并选择不透明的背景色。我在相对布局中使用了以下代码,结果非常接近:

    <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>

我已经按照您的要求创建了上面的布局。请参考下面的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>