Ich habe eine schwierige Zeit versucht, meine 2 linearen Layouts zu zentrieren. Im ersten linearen Layout wird der Ländercode ausgewählt und der Text in derselben Zeile bearbeitet. Das zweite lineare Layout ist angenommen, um die Schaltfläche unter dem ersten linearen Layout zu platzieren. Aber wenn ich den Knopf unter das erste lineare Layout setze, wird es nicht mehr zentriert.Zentrieren von 2 verschiedenen Layouts in einer XML-Datei
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/ghostWhiteColor"
android:orientation="vertical"
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"
android:gravity="center"
android:id="@+id/linearLayout1">
<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="86dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
app:ccp_showFullName="false"
app:ccp_showNameCode="false"
app:ccp_showPhoneCode="true" />
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/register_password"
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginTop="-2dp"
android:hint="@string/hint_phone"
android:inputType="phone"
android:padding="10dp"
android:singleLine="true"
app:met_floatingLabel="normal"
app:met_helperText="Enter your phone number."
app:met_helperTextAlwaysShown="true" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="10dp"
android:gravity="center">
<com.rey.material.widget.Button
android:id="@+id/button_register_accept"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/holo_blue_light"
android:padding="10dp"
android:paddingEnd="50dp"
android:text="@string/btn_accept"
android:textColor="@color/ghostWhiteColor" />
</LinearLayout>
</RelativeLayout>
Beispiel für etwas nicht zentriert. https://puu.sh/yruSe/0721745d0b.png
könnten Sie setzen einen Screenshot von dem, was Sie wollen? – diegoveloper
@diegoveloper Aktueller Thread eines Beispiels für etwas, das nicht zentriert ist. – user8924538
ok überprüfen Sie meine Lösung unten – diegoveloper