私は3つの子供の線形レイアウトが縦向きの親線形レイアウトのxmlスクリーンを持っています。最初の子には画像ビューが含まれています。アプリケーションを実行すると、画像は表示されません。どうして?画像サイズが大きすぎますか?もしそうなら..それをどのようにスケールするのですか?しかし、イメージは私のデザインタブで見ることができます。 android stdudioの以下はXMLファイルの完全なコードです。イメージを線形レイアウトの中心に合わせるにはどうすればいいですか?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_sign_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.root.my_laoder.SignUp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="@drawable/ty"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="50dp"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp"
>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
/>
</LinearLayout>
</LinearLayout>
を'heightとwidth'の両方に対して' wrap_content'を実行してください。 –
私はそれをやったし、私も編集したコードをscaletypeでチェックしようとしました。結果はありません:( –
あなたがスナップショットを提供できるなら、もっと簡単になります。また、画像の中央に合わせるには、imageviewを含む線形レイアウトに 'android:gravity =" centre_vertical | centre_horizontal "'を入れなければなりません –