Ich versuche Texteingabekomponenten mit der Größe des Bildschirms übereinstimmen. Zum Beispiel möchte ich so aussehen. ThisRaster-Layout-Elemente, um die übergeordnete Größe anzupassen
jedoch, wenn die Größe des Bildschirms größer ist, ist das, was ich bekomme. This
Also, hier ist mein Code.
<GridLayout
android:layout_below="@+id/TopBarLayout"
android:layout_above="@+id/BottomBarLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="30dp"
android:id="@+id/PatientLayout"
android:rowCount="6"
android:columnCount="1">
<EditText
style="@style/Editor"
android:layout_width="match_parent"
android:id="@+id/PatientFirstNameEditText"
android:hint="@string/FirstNameHint"
android:layout_row="0"
android:layout_column="0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<EditText
style="@style/Editor"
android:layout_width="match_parent"
android:id="@+id/PatientLastNameEditText"
android:hint="@string/LastNameHint"
android:layout_row="1"
android:layout_column="0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<EditText
style="@style/Editor"
android:layout_width="match_parent"
android:id="@+id/PatientMiddleNameEditText"
android:hint="@string/MiddleNameHint"
android:layout_row="2"
android:layout_column="0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<LinearLayout
android:id="@+id/TopBarLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_weight="100"
android:background="#e8e8f5"
android:layout_row="3"
android:layout_column="0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<EditText
android:inputType="date"
style="@style/Editor"
android:id="@+id/DateOfBirthEditText"
android:layout_weight="90"
android:layout_width="0dp" />
<ImageButton
android:src="@drawable/calendar"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="10"
android:id="@+id/ShowDatePickerButton"
android:background="@android:color/transparent"
android:layout_marginTop="5.0dp"
android:layout_marginBottom="5.0dp" />
</LinearLayout>
<EditText
style="@style/Editor"
android:layout_width="match_parent"
android:id="@+id/PatientSocialSecurityNumberEditText"
android:hint="@string/SocialSecurityNumberHint"
android:layout_row="4"
android:layout_column="0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<RadioGroup
android:id="@+id/TopBarLayout"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="5"
android:layout_column="0"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<RadioButton
android:text="@string/Male"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/PatientMaleRadioButton"
android:checked="true" />
<RadioButton
android:text="@string/Female"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/PatientFemaleRadioButton" />
</RadioGroup>
</GridLayout>
Ich habe Ränder eingestellt, so dass es 5inch Bildschirm übereinstimmen würde. Ich möchte Komponenten an die Größe des Bildschirms anpassen. Wenn beispielsweise der Bildschirm klein ist, sollte der Text ebenfalls proportional kleiner sein. Ich möchte das gleiche Ergebnis von Rasterlayout als von der Grid-Panel von C# winform erhalten. Danke!
Haben Sie versucht, mehrere XML-Dateien zu verwenden, um verschiedene Bildschirmgrößen zu unterstützen? –
Und warum verwenden Sie Rasterlayout, um einzelne Spalten anzuzeigen? Warum gehst du nicht für LinearLayout? –