方向布局教程不完整

时间:2018-06-20 11:39:22

标签: android

我是新手, 谁能指导我如何使用我上传的[image]在下面更改代码,我真的很困惑,因为我不知道如何更改当前代码。

我尝试获得image] 1的图片,但当前图片为current image 我尝试了几种方法,例如更改高度的方向或布局,但仍然保持不变

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">


    <LinearLayout
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="4dp"
        android:text="Team A" />

    <TextView
        android:id="@+id/team_a_score"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="4dp"
        android:text="0" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addThreeForTeamA"
        android:text="+3 Points" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addTwoForTeamA"
        android:text="+2 Points" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addOneForTeamA"
        android:text="Free throw" />


    <LinearLayout
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="4dp"
        android:text="Team B" />

    <TextView
        android:id="@+id/team_b_score"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="4dp"
        android:text="0" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addThreeForTeamA"
        android:text="+3 Points" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addTwoForTeamA"
        android:text="+2 Points" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:onClick="addOneForTeamA"
        android:text="Free throw" />

    </LinearLayout>

1 个答案:

答案 0 :(得分:0)

你去哪里

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:weightSum="2"
 android:orientation="horizontal">


<LinearLayout
    android:layout_weight="1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="4dp"
    android:text="Team A" />

<TextView
    android:id="@+id/team_a_score"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="4dp"
    android:text="0" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addThreeForTeamA"
    android:text="+3 Points" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addTwoForTeamA"
    android:text="+2 Points" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addOneForTeamA"
    android:text="Free throw" />

</LinearLayout>


<LinearLayout
    android:layout_weight="1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="4dp"
    android:text="Team B" />

<TextView
    android:id="@+id/team_b_score"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="4dp"
    android:text="0" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addThreeForTeamA"
    android:text="+3 Points" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addTwoForTeamA"
    android:text="+2 Points" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:onClick="addOneForTeamA"
    android:text="Free throw" />

</LinearLayout>

</LinearLayout>
相关问题