Android上の要素でフルスクリーンの行を表示する方法はありますか? テーブル、GridView、リニアでそれをやろうとしましたが、かなりの時間をかけて苦労しています。短い時点で http://i.imgur.com/W0oTyaC.pngAndroidの簡易パーセンテージレイアウト?
:
私はちょうど私が何をしたいかの小さな絵を作っ
ラベルとボタンだけで、その内容やフィットと同じ大きさでなければなりません
ボタンは右側に貼り付ける必要があります。
ラベルは左側に
を守らなければならないテキストボックスはちょうどラベル/ボタン間の残りのスペースを埋める必要がありますが、大きなコンテンツの場合には、それは右のボタンを「追い出す」べきではありません。 ..
私が最後に試したのは、一種の許容可能なGridViewでしたが、実際はそうではありませんでした。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add nutrition part"
android:id="@+id/textView"
android:layout_column="0"
android:layout_row="0"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
<TextView
android:text="Selected part"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView15"
android:layout_column="0"
android:layout_row="1"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:text=""
android:enabled="false"
android:id="@+id/dialogMakeMealPartNutrition"
android:layout_column="1"
android:layout_row="1"
android:layout_columnSpan="1"
android:layout_rowSpan="1"
android:layout_gravity="fill_horizontal" />
<Button
android:text="Find nutrition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonMakeMealPartFindNutrition"
android:layout_column="2"
android:layout_row="1"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
<TextView
android:text="Gram"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView17"
android:layout_column="0"
android:layout_row="2"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:id="@+id/dialogMakeMealPartGram"
android:layout_column="1"
android:layout_row="2"
android:layout_columnSpan="1"
android:layout_rowSpan="1"
android:layout_gravity="fill_horizontal" />
<Button
android:text="Abort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogMakeMealPartButtonAbort"
android:layout_column="0"
android:layout_row="3"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
<Button
android:text="Add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogMakeMealPartButtonAdd"
android:layout_column="1"
android:layout_row="3"
android:layout_columnSpan="1"
android:layout_rowSpan="1" />
</GridLayout>
</ScrollView>
</RelativeLayout>
EDIT:
ConstraintLayoutが私の目的のために、非常に良い仕事をした - 良いヒントルカのための感謝:
:は、コードは次のようになります
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#FFFFFF">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Add nutrition part"
android:id="@+id/headline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:text="Selected part"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView15"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/buttonMakeMealPartFindNutrition" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="text"
android:text=""
android:enabled="false"
android:id="@+id/dialogMakeMealPartNutrition"
app:layout_constraintStart_toEndOf="@+id/textView15"
app:layout_constraintEnd_toStartOf="@+id/buttonMakeMealPartFindNutrition"
app:layout_constraintTop_toTopOf="@+id/buttonMakeMealPartFindNutrition" />
<Button
android:text="Find nutrition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonMakeMealPartFindNutrition"
app:layout_constraintTop_toBottomOf="@+id/headline"
app:layout_constraintStart_toEndOf="@+id/dialogMakeMealPartNutrition"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:text="Gram"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView17"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dialogMakeMealPartNutrition" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:id="@+id/dialogMakeMealPartGram"
app:layout_constraintStart_toStartOf="@+id/dialogMakeMealPartNutrition"
app:layout_constraintEnd_toEndOf="@+id/dialogMakeMealPartNutrition"
app:layout_constraintTop_toBottomOf="@+id/dialogMakeMealPartNutrition" />
<Button
android:text="Abort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogMakeMealPartButtonAbort"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dialogMakeMealPartGram" />
<Button
android:text="Add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogMakeMealPartButtonAdd"
app:layout_constraintStart_toEndOf="@+id/dialogMakeMealPartButtonAbort"
app:layout_constraintTop_toBottomOf="@+id/dialogMakeMealPartGram" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
</RelativeLayout>
はあなたがグリッドレイアウトやその他の – Raj
いいえ、didtnワークを使用して目標を達成しています(または私は推測するか、知らない)、私は、GridLayoutのを試してみましたしかし、このボタンはスクロールアウトされ、残りのスペースをちょうど埋めるためにテキストボックスを取得することはできません – Leorekk
'...残っているスペースをちょうど埋める' 'wrap_content'の代わりに' match_parent'を使用してください –