Android algunos de los elementos de vista no visibles
Frecuentes
Visto 1,076 veces
0
I am creating a layout as below but the checkbox element is not visible on the scren where am i goign wrong ?
<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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SeekBar android:id="@+id/seek"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:progress="50"/>
...and a few more elements here.
</LinearLayout>
<CheckBox android:id="@+id/CheckBox"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="somestring" />
</LinearLayout>
5 Respuestas
1
Programas de LinearLayout
antes de CheckBox
tiene su altura establecida en MATCH_PARENT
(and it fills all the parent's height) and the parent LinearLayout
of both has the orientation set to vertical so the CheckBox
es expulsado de la pantalla.
Establecer la altura del LinearLayout
que contiene el SeekBar
a WRAP_CONTENT
por ejemplo.
Respondido 24 ago 12, 07:08
0
You need to set your inner Linear Layout's height and width to wrap content. Try this.
<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:orientation="horizontal" >
<SeekBar
android:id="@+id/seek"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:progress="50" />
</LinearLayout>
<CheckBox
android:id="@+id/CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="somestring" />
</LinearLayout>
Respondido 24 ago 12, 07:08
0
Prueba esto :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="9"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/seek"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:progress="50" />
</LinearLayout>
<CheckBox
android:id="@+id/CheckBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="somestring" />
</LinearLayout>
Respondido 24 ago 12, 07:08
0
In your layout chose one element that you want to be flexible in size, say height wise. Then make its height="0dp"
y weight="1"
. Make heights of rest of elements: height="wrap_content"
.
Also you may have given discreet size of some dp to your other elements, and hence their total height runs out of available screen space OR there are too many elements that they go beyond your screen height. In this case, wrap your layout in a ScrollView
.
Respondido 24 ago 12, 07:08
0
change your LinerLayout definition it cannot be android:layout_height="match_parent"
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
if you set match_parent for linearlayout it consumes all content so wrap_content is better. But if you set it as I wrote checkbox will be at bottom page a linearlayout will consumes remaing part of screen.
Respondido 24 ago 12, 08:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android or haz tu propia pregunta.