【问题标题】:Android Layout TextViewAndroid 布局 TextView
【发布时间】:2016-07-28 21:23:08
【问题描述】:

我怎样才能适应这个文本视图,这样它就不会变形 2 个图像按钮。我想把它放在它们上面 2。 这就是它们现在的样子:

Layout now

This is how the buttons should look like:

这是我的 xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">



<ImageButton
    android:layout_width="0dp"
    android:layout_height="400dp"
    android:layout_weight="1"
    android:id="@+id/botoAbdominals"
    android:background="@drawable/abdominals"
    android:contentDescription="ImatgeAbdominals"
    android:layout_marginTop="50dp"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_gravity="center"
    />


<ImageButton
    android:layout_width="0dp"
    android:layout_height="400dp"
    android:layout_weight="1"
    android:id="@+id/botoFlexio"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:background="@drawable/flexio"
    android:contentDescription="ImatgeFlexio"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Escull la rutina desitjada" />

【问题讨论】:

  • 把 textview 放到你的线性布局之外

标签: java android android-layout android-studio


【解决方案1】:

在其周围放置另一个LinearLayout,即垂直方向。使用 textview 和 Linearlayout 作为它的子级。

以下层次结构。

> LinearLayout (vertical)
  > TextView
  > LinearLayout (horizontal) // [Like your current one]
    > ImageButton
    > ImageButton

【讨论】:

  • @AlexiaWhite 很高兴听到这个消息。并且您自己管理它而没有我发布完整代码:)
【解决方案2】:

这样做,使用这种布局安排:

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

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Escull la rutina desitjada" />

    <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="2"
    android:orientation="horizontal">

        <ImageButton
        android:layout_width="0dp"
        android:layout_height="400dp"
        android:layout_weight="1"
        android:id="@+id/botoAbdominals"
        android:background="@drawable/abdominals"
        android:contentDescription="ImatgeAbdominals"
        android:layout_marginTop="50dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_gravity="center"/>


        <ImageButton
        android:layout_width="0dp"
        android:layout_height="400dp"
        android:layout_weight="1"
        android:id="@+id/botoFlexio"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/flexio"
        android:contentDescription="ImatgeFlexio"/>

   </LinearLayout>


</LinearLayout>

【讨论】:

    猜你喜欢
    • 2016-08-07
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 2014-07-17
    • 2012-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多