Это мой 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"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="8 diciembre, 2015"
android:id="@+id/txtFecha"
android:textAlignment="textEnd"
android:layout_margin="5dp"
android:layout_gravity="right" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_margin="10dp">
<TextView
android:layout_width="0dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text"
android:id="@+id/txtTituloNot"
android:layout_height="wrap_content"
android:maxHeight="52dp"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/feclaabajo"
android:layout_below="@+id/txtTituloNot"
android:scaleType="fitXY"
android:adjustViewBounds="false"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text Medium Text Medium Text Medium Text
Medium Text Medium Text Medium Text Medium Text Medium Text
Medium Text Medium Text Medium Text Medium Text Medium Text
Medium Text Medium Text Medium Text Medium Text Medium Text Medium"
android:id="@+id/txtExtracto"
android:layout_margin="5dp"
android:maxHeight="110dp"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="233dp"
android:layout_height="170dp"
android:id="@+id/imageViewNoticia"
android:src="@drawable/imagenodisponible"
android:soundEffectsEnabled="false"
android:layout_gravity="center_horizontal"
android:scaleType="fitXY"
android:layout_marginBottom="7dp" />
</LinearLayout>
Но сейчас я работаю с ниже код только:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_margin="10dp">
<TextView
android:layout_width="0dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text Large Text"
android:id="@+id/txtTituloNot"
android:layout_height="wrap_content"
android:maxHeight="52dp"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/feclaabajo"
android:layout_below="@+id/txtTituloNot"
android:scaleType="fitXY"
android:adjustViewBounds="false"
android:layout_weight="1" />
</LinearLayout>
Как вы видели ImageView и TextView имеют
android:layout_weight="1"
Но это видеть, как его:
Вид изображения не видит, и Textview
имеет 100%
любое значение я устанавливаю в Imageview
это не меняет
Теперь, если изменить значение текста, но значение от 0 до .99 (вид изображения еще с 1 по весу)
Это отлично работает, если я использую (.75 и .25), но он не работает, если я ставлю 3 и 1 Я хотел бы иметь возможность использования в последнем
Вы установили 'android: weightSum =" 1 "' на LinearLayout. Либо измените его на фактическую сумму, либо просто удалите. –