首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >定向布局教程不完整

定向布局教程不完整
EN

Stack Overflow用户
提问于 2018-06-20 11:39:22
回答 1查看 32关注 0票数 0

我是个新手,谁能指导我怎么用上传的图片修改下面的代码,我真的很困惑,因为我不知道如何改变当前的代码。

我尝试实现的图像是图像]1,但是当前的图像是当前图像,我尝试过很少的方法,比如改变高度的方向或布局,但仍然保持不变。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-20 12:14:06

这就是你要的

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50947365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档