2012-04-18 4 views
0

У меня проблема с RelativeLayout, я не знаю, как добавить scrollview, я хочу сохранить все мои объекты в относительной компоновке, и я не хочу добавлять еще один linearlayout, также обратите внимание, что у меня есть фон установленный в моем RelativeLayout, спасибо, у меня также есть проблема при использовании .gone-функции для моего изображения в относительном макете, изображение появляется при обновлении представления, у меня не было этого pb при использовании linearlayout вот мой код:RelativeLayout и ScrollView

<?xml version="1.0" encoding="utf-8"?> 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="0.80" 
    android:background="@drawable/questionggreen" 
    android:orientation="vertical" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 






    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/imageView1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="14dp" 
     android:clipToPadding="true" 
     android:orientation="vertical" > 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" 24 Juin 1944" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 

     <RadioButton 
      android:id="@+id/radio2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" 9 Decembre 1988" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="14 octobre 1978" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 




     <TextView 
      android:id="@+id/Chrono" 
      android:layout_width="wrap_content" 
      android:layout_height="20dp" 
      android:layout_gravity="center" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#000000" 
      android:textStyle="bold" android:layout_marginTop="2dp"/> 

    </RadioGroup> 

    <TextView 
     android:id="@+id/Lareponseetait" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" /> 

    <TextView 
     android:id="@+id/QuestionNumber" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_weight="1.26" 
     android:text="Question 1" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#00ff00" 
     android:textStyle="normal|bold" /> 

    <TextView 
     android:id="@+id/Question" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/QuestionNumber" 
     android:layout_marginTop="30dp" 
     android:text="Quelle est la date de naissance de Usher ?" 
     android:textColor="#FFFACD" 
     android:textSize="16dp" 
     android:textStyle="normal|bold" 
     android:typeface="sans" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="158dp" 
     android:layout_height="154dp" 
     android:layout_below="@id/Question" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="32dp" 
     android:src="@drawable/mzl" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_weight="1.26" 
     android:text="CELB" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 



    <TextView 
     android:id="@+id/Goodanswercount" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Goodanswercount" 
     android:layout_alignLeft="@+id/radioGroup1" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/radioGroup1" 
     android:layout_marginTop="3dp" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#00ff00" 
     android:textStyle="bold" android:layout_toRightOf="@id/textView1"/> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignTop="@+id/Goodanswercount" 
     android:text="Correct :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#00ff00" android:layout_marginTop="3dp"/> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/Goodanswercount" 
     android:text="Wrong :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" android:layout_toLeftOf="@+id/Goodanswercount"/> 

    <TextView 
     android:id="@+id/Wronganswercount" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/textView2" 
     android:layout_toRightOf="@+id/textView2" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#ff0000" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/Lareponseetait" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/QuestionNumber" 
     android:text="La reponse etait :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" android:layout_marginTop="5dp"/> 

    <TextView 
     android:id="@+id/Lareponsecorrectetait" 
     android:layout_width="215dp" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/Lareponseetait" 
     android:layout_alignBottom="@+id/Lareponseetait" 
     android:layout_alignParentRight="true" 
     android:text="Small Text" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" /> 

    <TextView 
     android:id="@+id/Scores1" 
     android:layout_width="29dp" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Question" 
     android:layout_alignParentRight="true" 
     android:text="000" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff00ff" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/Scores" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Question" 
     android:layout_toLeftOf="@+id/Scores1" 
     android:text="Scores : 00" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff00ff" 
     android:textStyle="bold" /> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView2" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/buttonok" android:layout_marginTop="10dp"/> 

    <CheckBox 
     android:id="@+id/checkBox1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/imageButton1" 
     android:text="Sounds Off" android:layout_marginTop="3dp"/> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/checkBox1" 
     android:layout_alignBottom="@+id/checkBox1" 
     android:layout_alignParentLeft="true" 
     android:text="Quit" /> 

</RelativeLayout> 

ответ

0

Try т его. это полезно для вас ...

<?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" 
android:background="@drawable/background"> 
<ScrollView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/scrollView1" android:layout_weight="0.97"> 
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="444dp"> 
     <TextView android:id="@+id/textView1" android:textColor="@color/myGreenColor" android:text="Enter Roll Number and Exam hear" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true"></TextView> 
     <ImageView android:src="@drawable/result" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageView1" android:layout_below="@+id/textView1" android:layout_alignParentLeft="true" android:layout_marginTop="22dp" android:layout_alignParentRight="true"></ImageView> 
     <Spinner android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:layout_alignParentRight="true" android:layout_marginTop="32dp" android:layout_width="150dp" android:id="@+id/searchRsult_spinner"></Spinner> 
     <EditText android:layout_height="wrap_content" android:inputType="text|textPersonName" android:layout_width="wrap_content" android:layout_below="@+id/searchRsult_spinner" android:layout_alignParentLeft="true" android:layout_marginTop="16dp" android:layout_alignParentRight="true" android:id="@+id/searchResult_txtRollNumber"> 
      <requestFocus></requestFocus> 
     </EditText> 
     <Button android:layout_height="wrap_content" android:text="Show result" android:id="@+id/button1" android:layout_below="@+id/searchResult_txtRollNumber" android:layout_alignParentLeft="true" android:layout_marginTop="33dp" android:layout_width="200dp" android:textColor="@color/myColorBlue"></Button> 
     <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Cancel" android:id="@+id/button2" android:layout_alignBaseline="@+id/button1" android:layout_alignBottom="@+id/button1" android:layout_toRightOf="@+id/button1" android:layout_alignParentRight="true" android:textColor="@color/myColorBlue"></Button> 
    </RelativeLayout> 
</ScrollView> 

0

Попробуйте это:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
<RelativeLayout 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="0.80" 
    android:background="@drawable/questionggreen" 
    android:orientation="vertical" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > 






    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/imageView1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="14dp" 
     android:clipToPadding="true" 
     android:orientation="vertical" > 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" 24 Juin 1944" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 

     <RadioButton 
      android:id="@+id/radio2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" 9 Decembre 1988" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="14 octobre 1978" 
      android:textColor="#ff00ff" 
      android:textSize="19dp" 
      android:textStyle="bold" /> 




     <TextView 
      android:id="@+id/Chrono" 
      android:layout_width="wrap_content" 
      android:layout_height="20dp" 
      android:layout_gravity="center" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#000000" 
      android:textStyle="bold" android:layout_marginTop="2dp"/> 

    </RadioGroup> 

    <TextView 
     android:id="@+id/Lareponseetait" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" /> 

    <TextView 
     android:id="@+id/QuestionNumber" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_weight="1.26" 
     android:text="Question 1" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#00ff00" 
     android:textStyle="normal|bold" /> 

    <TextView 
     android:id="@+id/Question" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/QuestionNumber" 
     android:layout_marginTop="30dp" 
     android:text="Quelle est la date de naissance de Usher ?" 
     android:textColor="#FFFACD" 
     android:textSize="16dp" 
     android:textStyle="normal|bold" 
     android:typeface="sans" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="158dp" 
     android:layout_height="154dp" 
     android:layout_below="@id/Question" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="32dp" 
     android:src="@drawable/mzl" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_weight="1.26" 
     android:text="CELB" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 



    <TextView 
     android:id="@+id/Goodanswercount" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Goodanswercount" 
     android:layout_alignLeft="@+id/radioGroup1" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/radioGroup1" 
     android:layout_marginTop="3dp" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#00ff00" 
     android:textStyle="bold" android:layout_toRightOf="@id/textView1"/> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignTop="@+id/Goodanswercount" 
     android:text="Correct :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#00ff00" android:layout_marginTop="3dp"/> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/Goodanswercount" 
     android:text="Wrong :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" android:layout_toLeftOf="@+id/Goodanswercount"/> 

    <TextView 
     android:id="@+id/Wronganswercount" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/textView2" 
     android:layout_toRightOf="@+id/textView2" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#ff0000" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/Lareponseetait" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/QuestionNumber" 
     android:text="La reponse etait :" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" android:layout_marginTop="5dp"/> 

    <TextView 
     android:id="@+id/Lareponsecorrectetait" 
     android:layout_width="215dp" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/Lareponseetait" 
     android:layout_alignBottom="@+id/Lareponseetait" 
     android:layout_alignParentRight="true" 
     android:text="Small Text" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff0000" /> 

    <TextView 
     android:id="@+id/Scores1" 
     android:layout_width="29dp" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Question" 
     android:layout_alignParentRight="true" 
     android:text="000" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff00ff" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/Scores" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Question" 
     android:layout_toLeftOf="@+id/Scores1" 
     android:text="Scores : 00" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="#ff00ff" 
     android:textStyle="bold" /> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView2" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/buttonok" android:layout_marginTop="10dp"/> 

    <CheckBox 
     android:id="@+id/checkBox1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/imageButton1" 
     android:text="Sounds Off" android:layout_marginTop="3dp"/> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/checkBox1" 
     android:layout_alignBottom="@+id/checkBox1" 
     android:layout_alignParentLeft="true" 
     android:text="Quit" /> 

</RelativeLayout> 
</ScrollView> 
+0

Спасибо вам большое его работы, но теперь, я хочу Отключить Scrollview, когда я не нужен, кроме того, я хочу скрыть вид изображения с picture.setvisibility (View.GONE) в методе onCreate, его работа при запуске, но когда графический интерфейс обновляется, изображение возвращается снова – CELB

+0

Попробуйте сделать это в методе onResume() – FUBUs

+0

не работает, используя метод onResume(), также он можно отключить прокрутку, когда мне это не нужно? Благодарю. – CELB

Смежные вопросы