J'ai utilisé toutes les ressources possibles ici et rien n'a fonctionné. Je ne peux pas jouer pour centrer mon ImageView.Problème centrant un ImageView dans LinearLayout
Je vais poster le code et ce qu'il affiche, et espère que quelqu'un comprend ..
Une partie importante est le ImageView. Code Posté complet pour la compréhension approfondie
<?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="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:orientation="horizontal"
android:background="@drawable/tile_light_selector">
<ImageView
android:id="@+id/phone_icon"
android:layout_width="150dip"
android:layout_height="150dip"
android:scaleType="fitXY"
android:layout_gravity="center_vertical"
android:background="@drawable/phone_icon"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/tile_dark_selector">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/tile_dark_selector">
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/tile_light_selector">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/tile_light_selector">
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:background="@drawable/tile_dark_selector">
</LinearLayout>
</LinearLayout>
</LinearLayout>
Toutes les idées?
'android: layout_gravity = "center_vertical"' peut-être cela devrait être '' center_horizontal' ou center'? – Gudin
set android: gravity = "center" à la disposition linéaire contenant l'imageview –
Centré à où? changer 'android: layout_gravity =" center_vertical "' à 'android: layout_gravity =" center "' – RobVoisey