2012-05-07 2 views
1

Добро пожаловать.ScrollView Android

У меня проблема с Scrollview.

Это именно то, что кнопки, расположенные внизу, должны быть каждый раз одинакового размера, а текст из чекбокса должен быть перемещен.

Что я делаю неправильно?

Ниже приведен код:

<?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" > 

    <TextView 
     android:id="@+id/tvKtorePytanie" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:text="1/10" /> 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="220dp" 
     android:layout_height="180dp" 
     android:src="@drawable/icon" 
     android:layout_gravity="center" /> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/linearLayout2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/tvPytanie" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:text="Pytanie" 
       android:textSize="16sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz3" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 
     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="bottom" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/bPoprzednie" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Poprzednie" /> 

     <Button 
      android:id="@+id/bSprawdz" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Sprawdź" /> 

     <Button 
      android:id="@+id/bNastepne" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Następne" /> 
    </LinearLayout> 

</LinearLayout> 
+0

Может быть, вы можете быть более ясно, о том, что вы пытаетесь сделать, и в чем проблема? –

ответ

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/tvKtorePytanie" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="right" 
      android:text="1/10" /> 

     <ImageView 
      android:id="@+id/imageView" 
      android:layout_width="220dp" 
      android:layout_height="180dp" 
      android:layout_gravity="center" 
      android:src="@drawable/ic_launcher" /> 
    </LinearLayout> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/linearLayout2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/tvPytanie" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:text="Pytanie" 
       android:textSize="16sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 

      <CheckBox 
       android:id="@+id/cbOdpowiedz3" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="1dip" 
       android:text="CheckBox" 
       android:textSize="10sp" /> 
     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:gravity="bottom" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/bPoprzednie" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Poprzednie" /> 

     <Button 
      android:id="@+id/bSprawdz" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Sprawdź" /> 

     <Button 
      android:id="@+id/bNastepne" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Następne" /> 
    </LinearLayout> 

</LinearLayout> 
+0

i post ur код с некоторыми изменениями в линейном макете применять весы в макете проверить это –

0

ScrollView содержит всю ширину доступного экрана. Вы должны указать фиксированную (статическую) высоту в dpi или px, чтобы вы могли установить кнопку прямо ниже ScrollView.

+0

Супер это помогает, но если у нас есть другое разрешение экрана, это позор, чтобы потерять место. Поэтому я ищу универсальное решение. –

+0

Использование dpi, оно позволит решить вашу проблему до некоторой степени, так как она использует плотность экрана на дюйм. Другим решением является получение высоты экрана и установка высоты ScrollView в коде в соответствии с высотой экрана. – MrWaqasAhmed

0

Используйте относительную компоновку в качестве родительского макета. делают «linearLayout2» сделать это как alignParentBottom = «истинный»

+0

Хорошо, я использовал RelativeLayout, но теперь у меня есть эта проблема: http://img14.imageshack.us/img14/69/123siy.jpg Я хотел, чтобы субтитры не попадали под кнопки. –

+0

теперь на вашем наборе ScollView android: paddingBottom = "60dip" –

0

попробовать этот вывод

<LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true"> 
     <----put your items here----> 
</LinearLayout>