私はログイン用のレイアウトを設計しています。しかし、私はレイアウトの重心を設定したい(フルレイアウトのコンテンツを画面の中央に設定)。私は重力センターを使用していますが、それは私に適切な出力を与えていないので、別の問題で問題が発生している可能性があります。ベローは私のレイアウトのXMLコードです。だから誰かが私に問題がある場所を教えてもらえますか?レイアウトの重心を設定するには
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="30dp"
android:paddingLeft="20dp"
android:layout_marginTop="10dp"
android:background="#458221"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
<!-- I want to set this layout into the center of the screen ,This layout cann't set the gravity center -->
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name: "
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="user"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="password"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="pass"
/>
</LinearLayout>
</LinearLayout>
たくさん仕組みを理解します。パフォーマンスの悪いアラート。そして、あなたはセンターではどういう意味ですか?縦、横、またはスクリーンで? –
1つのレイアウトに2つのレイアウトを追加するだけです。だから、なぜそれはパフォーマンスの悪い警告です。あなたが私にそれに関する情報をくれば、私は恩恵を受けるでしょう。あなたに感謝したこと – opu
線形レイアウト内に1つの子テキストビューがありますが、findviewbyidがすべてのネストでコストがかかるようなネストを避ける必要があります –