私はアプリケーションを開発しており、現在グラフィカル インターフェイスに取り組んでいます。画面の中央に最初のimageViewを配置したいと思います。属性を使用しandroid:layout_gravity="center_horizontal"
ましたが、画面の左側に画像が表示されます。
とsLinearLayout
を含む秒を定義したからですか? テキスト要素の重みと、ボタンを含む水平方向の重みを定義するために定義しました。ImageView
textView
LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/ebay"/> <!-- a modifier plus tard -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_gravity="left"
android:text="Book : "
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Sea change"
android:textSize="25sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_gravity="left"
android:text="ISBN"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="246546524"
android:textSize="30sp"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="OK"/>
</LinearLayout>
どうすれば画面の中央に表示できますか?