relative layout bottom buttons goes up - android

I have a relative layout with scrollview. In My relative layout i have few image buttons and radio group when i select the radio option the bottom image view android:id="#+id/sol_btn
goes up.
Why its goes up? what mistake in my layout? And in my manifest also i have used this
android:windowSoftInputMode="stateHidden|adjustPan"
My layout code here:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".Quesans">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/que_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:text="TextView" />
<ImageView
android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/que_txt"
android:layout_marginTop="15dp"
android:layout_marginBottom="40dp"
android:layout_below="#+id/que_txt"/>
<RadioGroup
android:id="#+id/rdgroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image"
android:orientation="vertical" >
<RadioButton
android:id="#+id/RB1"
android:text=""/>
<RadioButton
android:id="#+id/RB2"
android:text=""/>
<RadioButton
android:id="#+id/RB3"
android:text=""/>
<RadioButton
android:id="#+id/RB4"
android:text=""/>
</RadioGroup>
<TextView
android:id="#+id/rdtxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/rdgroup"
android:layout_marginTop="40dp"
android:text="Nothing is picked"
android:textColor="#0000FF"/>
<ImageView
android:id="#+id/nxt_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/rdtxt"
android:layout_marginRight="22dp"
android:layout_marginTop="40dp"
android:src="#drawable/next_pressed" />
<ImageView
android:id="#+id/focusarea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/nxt_btn"
android:layout_below="#+id/nxt_btn"
android:layout_marginRight="1dp"
android:layout_marginTop="10dp"
android:src="#drawable/focusarea_pressed" />
<ImageView
android:id="#+id/app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="140dp"
android:layout_marginBottom="0dp"
android:src="#drawable/newapps" />
<ImageView
android:id="#+id/prv_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/image"
android:layout_alignTop="#+id/nxt_btn"
android:src="#drawable/previous_pressed" />
<ImageView
android:id="#+id/sol_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/prv_btn"
android:layout_below="#+id/prv_btn"
android:layout_marginTop="10dp"
android:layout_marginLeft="1dp"
android:src="#drawable/solution_pressed" />
</RelativeLayout>
</ScrollView>

I have changed images to default. Edit xml file and try this,it will work fine.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/que_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:text="TextView" />
<ImageView
android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/que_txt"
android:layout_below="#+id/que_txt"
android:layout_marginBottom="40dp"
android:layout_marginTop="15dp"
android:background="#drawable/ic_launcher" />
<RadioGroup
android:id="#+id/rdgroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image"
android:orientation="vertical" >
<RadioButton
android:id="#+id/RB1"
android:text="" />
<RadioButton
android:id="#+id/RB2"
android:text="" />
<RadioButton
android:id="#+id/RB3"
android:text="" />
<RadioButton
android:id="#+id/RB4"
android:text="" />
</RadioGroup>
<TextView
android:id="#+id/rdtxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/rdgroup"
android:layout_marginTop="40dp"
android:text="Nothing is picked"
android:textColor="#0000FF" />
<ImageView
android:id="#+id/focusarea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/nxt_btn"
android:layout_below="#+id/nxt_btn"
android:layout_marginRight="1dp"
android:layout_marginTop="10dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/sol_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/prv_btn"
android:layout_below="#+id/prv_btn"
android:layout_marginLeft="1dp"
android:layout_alignParentBottom="true"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/prv_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/image"
android:layout_below="#+id/rdtxt"
android:layout_marginTop="18dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/nxt_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/prv_btn"
android:layout_marginRight="18dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:baselineAlignBottom="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
</ScrollView>
Here is screenshot:

Your Solution Button(#+id/sol_btn) having Margin 10 dp to the previous button(#+id/prv_btn).,
So For the First question since the previous button will not be in the view your Solution button is going to the top of the view.
So Make the visibility of the previous button from View.Gone to View.Invisible.
Your problem will be solved:-

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".Quesans">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/que_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="25dp"
android:text="TextView" />
<ImageView
android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/que_txt"
android:layout_marginTop="15dp"
android:layout_marginBottom="40dp"
android:layout_below="#+id/que_txt"/>
<RadioGroup
android:id="#+id/rdgroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/image"
android:orientation="vertical" >
<RadioButton
android:id="#+id/RB1"
android:text=""/>
<RadioButton
android:id="#+id/RB2"
android:text=""/>
<RadioButton
android:id="#+id/RB3"
android:text=""/>
<RadioButton
android:id="#+id/RB4"
android:text=""/>
</RadioGroup>
<TextView
android:id="#+id/rdtxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/rdgroup"
android:layout_marginTop="40dp"
android:text="Nothing is picked"
android:textColor="#0000FF"/>
<ImageView
android:id="#+id/nxt_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/rdtxt"
android:layout_marginRight="22dp"
android:layout_marginTop="40dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/focusarea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/nxt_btn"
android:layout_below="#+id/nxt_btn"
android:layout_marginRight="1dp"
android:layout_marginTop="10dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="140dp"
android:layout_marginBottom="0dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/prv_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/image"
android:layout_alignTop="#+id/nxt_btn"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/sol_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/prv_btn"
android:layout_below="#+id/prv_btn"
android:layout_marginTop="10dp"
android:layout_marginLeft="1dp"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
</ScrollView>

Try setting android:focusable=false on your RadioGroup

Remove android:windowSoftInputMode="stateHidden|adjustPan" from your menifest. I have done like this.. It is not go up.

Related

Android how to design the xml about the UI

I need to design the xml about below layout.
I try to use RelativeLayout to design, but I don't know
how to adjust the imageVivew3 in RelativeLayout.
Have anyone can teach me how to adjust the xml?
or have you nice xml design about this layout?
thank you very much.
my xml is below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView1"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:layout_margin="0dp"/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView2"
android:visibility="visible"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:visibility="visible"
android:layout_centerVertical="true"
android:layout_below="#+id/imageView3"
android:layout_alignParentRight="true"
/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView4"
android:layout_alignTop="#+id/textView1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt1"
android:id="#+id/textView1"
android:textColor="#color/white"
android:textSize="#dimen/common_size_large"
android:layout_below="#+id/imageView3"
android:layout_alignParentRight="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt2"
android:id="#+id/textView2"
android:textColor="#color/white"
android:layout_below="#+id/textView1"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Try to LinearLayout instead of RelativeLayout..
And also use android:layout_weight atttribute ...code sample are given below... put this
code to your xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#android:color/white"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight=".75"
android:layout_marginTop="5dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="2"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/gerder"
android:textSize="12sp"
android:textStyle="bold"
android:contentDescription="#string/app_name"
android:layout_gravity="center"
android:paddingLeft="10dp"
android:gravity="center"
android:textColor="#android:color/black"
android:fontFamily="#string/providerFontFamily"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<RadioGroup
android:id="#+id/radioGender"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp"
>
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/providerGenderMale"
android:checked="true" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/providerGenderFemale" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="2"
android:layout_gravity="center"
>
<TextView
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#string/providerFontFamily"
android:text="#string/age_range"
android:gravity="left"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_gravity="center"
/>
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginRight="15dp"
android:prompt="#string/country_prompt"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Android ScrollView doesnt work

I'm trying to use scrollview in an app, but it doesn't work, the scroll bar doesn't appear and the buttons overlap, I'm using RelativeLayout to do this, I tried by other ways, but it doesn't work too.
Does someone know what I have to do?
Here is the code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:text="#string/Texto14"
android:id="#+id/buttonHomePerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="70dp"
android:text="#string/Texto15"
android:id="#+id/buttonIniciarConversaPerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:text="#string/Texto16"
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="20dp"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/imageViewPerfilV"
android:src="#drawable/ic_launcher"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto8"
android:id="#+id/textViewNomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_alignStart="#+id/buttonHomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto9"
android:id="#+id/textViewCursoPerfilV"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/textViewNomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto10"
android:id="#+id/textViewDataPerfilV"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginTop="45dp"
android:layout_marginLeft="20dp"
android:layout_alignParentStart="true" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Try it. I just removed Parent Layout RelativeLayout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/buttonHomePerfilV"
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:background="#333399"
android:text="#string/Texto14"
android:textColor="#ffffff" />
<Button
android:id="#+id/buttonIniciarConversaPerfilV"
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true"
android:layout_marginBottom="70dp"
android:background="#333399"
android:text="#string/Texto15"
android:textColor="#ffffff" />
<Button
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV"
android:layout_marginBottom="20dp"
android:background="#333399"
android:text="#string/Texto16"
android:textColor="#ffffff" />
<ImageView
android:id="#+id/imageViewPerfilV"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewNomePerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/buttonHomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_marginTop="20dp"
android:text="#string/Texto8"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewCursoPerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textViewNomePerfilV"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:text="#string/Texto9"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewDataPerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginLeft="20dp"
android:layout_marginTop="45dp"
android:text="#string/Texto10"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
</ScrollView>
You cannot use a RelativeLayout inside a ScrollView put the RelativeLayout inside a LinearLayout
Try this
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Linearlayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:text="#string/Texto14"
android:id="#+id/buttonHomePerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="70dp"
android:text="#string/Texto15"
android:id="#+id/buttonIniciarConversaPerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:text="#string/Texto16"
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="20dp"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/imageViewPerfilV"
android:src="#drawable/ic_launcher"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto8"
android:id="#+id/textViewNomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_alignStart="#+id/buttonHomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto9"
android:id="#+id/textViewCursoPerfilV"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/textViewNomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto10"
android:id="#+id/textViewDataPerfilV"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginTop="45dp"
android:layout_marginLeft="20dp"
android:layout_alignParentStart="true" />
</RelativeLayout>
</linearlayout>
</scrollview>

Listview item fits to row

I have a listview with two textviews in a row like name and result. I want to fit the textview to the row because I need to set a background color to the second textview.I have tried "match_parent"fill_parent"..etc
//items.xml
<ImageView
android:id="#+id/imgViewLogo"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txtViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtViewDescription"
android:layout_alignBottom="#+id/txtViewDescription"
android:layout_marginLeft="6dp"
android:layout_toRightOf="#+id/imgViewLogo"
android:text="TextView"
android:textStyle="bold" />
<MyTextView
android:id="#+id/txtViewDescription"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imgViewLogo"
android:layout_marginRight="33dp"
android:layout_gravity="center"
android:text="TextView"
android:textStyle="bold" />
<ImageView
android:id="#+id/temperrr"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/resultarrawnocolor" />
</RelativeLayout>
// listview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/gl1"
style="?android:attr/buttonStyleSmall"
android:layout_width="64dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/back"
android:gravity="center_vertical"
android:onClick="backMan" />
<TextView
android:id="#+id/textVie3"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/gl1"
android:background="#drawable/header_line" />
<Button
android:id="#+id/gl2"
style="?android:attr/buttonStyleSmall"
android:layout_width="64dp"
android:layout_height="40dp"
android:layout_above="#+id/textVie3"
android:layout_alignParentRight="true"
android:background="#drawable/info"
android:gravity="center_vertical"
android:onClick="info" />
<TextView
android:id="#+id/textVie1"
android:layout_width="135dp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/gl2"
android:layout_alignBottom="#+id/gl2"
android:layout_centerHorizontal="true"
android:background="#drawable/uchek_header"
android:gravity="center" />
<TextView
android:id="#+id/bgnf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textVie3"
android:background="#drawable/main_bag" />
<TextView
android:id="#+id/myTextView1"
android:layout_width="375dp"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/bgnf1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/textviewtableheader"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="Result"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="#+id/btnemail"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#drawable/email"/>
<Button
android:id="#+id/btnsave"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/save"
/>
<Button
android:id="#+id/btnrec"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/myTextView1"
android:background="#drawable/rec"
/>
<ListView
android:id="#+id/lv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/btnemail"
android:layout_alignLeft="#+id/myTextView1"
android:layout_alignRight="#+id/myTextView1"
android:layout_below="#+id/myTextView1"
android:background="#color/White"
android:divider="#drawable/tabledivider"
android:dividerHeight="1dp"
android:listSelector="#drawable/listcolor"
tools:listitem="#android:layout/simple_list_item_1" >
</ListView>
</RelativeLayout>
If you want the height to be of icon size you can use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:weightSum="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#F00"
android:gravity="center_vertical"
android:text="Envelope" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#990"
android:gravity="center_vertical"
android:text="1000ml/Dl" />
</LinearLayout>
</LinearLayout>
Try distributing the weight of ImageView , TextView , TextView and ImageView to get the desired result.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imgViewLogo"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linear_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/temperrr"
android:layout_toRightOf="#+id/imgViewLogo"
android:orientation="horizontal"
android:weightSum="1.0" >
<TextView
android:id="#+id/txtViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtViewDescription"
android:layout_alignBottom="#+id/txtViewDescription"
android:layout_toRightOf="#+id/imgViewLogo"
android:layout_weight="0.5"
android:background="#ff0000"
android:text="TextView"
android:textStyle="bold" />
<TextView
android:id="#+id/txtViewDescription"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imgViewLogo"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="#ffff00"
android:text="TextView"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/temperrr"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
may be this will help, i edited the answer,check now

ViewFliper in layout

i am doing one application in android but i have one problem in layout file
i am doing by viewFliper
here is code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/Quesiontext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="44dp"
android:text="#string/Question"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroupOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/Quesiontext"
android:layout_marginTop="30dp" >
<RadioButton
android:id="#+id/optionOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/option1" />
<RadioButton
android:id="#+id/optionTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option2" />
<RadioButton
android:id="#+id/optionthree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option3" />
<RadioButton
android:id="#+id/optionFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option4" />
</RadioGroup>
<TextView
android:id="#+id/corrertView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/radioGroupOptions"
android:layout_marginRight="48dp"
android:text="#string/correct" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/corrertView"
android:layout_below="#+id/corrertView"
android:layout_marginTop="42dp"
android:text="#string/Next"
android:textSize="16sp" />
<Button
android:id="#+id/Btnpervious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/btnNext"
android:layout_alignBottom="#+id/btnNext"
android:layout_alignParentLeft="true"
android:text="#string/Pervious"
android:textSize="16sp" />
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewFlipper
android:id="#+id/ViewFlipper01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/Quesiontext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="44dp"
android:text="#string/Question"
android:textSize="18sp" />
<RadioGroup
android:id="#+id/radioGroupOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/Quesiontext"
android:layout_marginTop="30dp" >
<RadioButton
android:id="#+id/optionOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/option1" />
<RadioButton
android:id="#+id/optionTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option2" />
<RadioButton
android:id="#+id/optionthree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option3" />
<RadioButton
android:id="#+id/optionFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option4" />
</RadioGroup>
<TextView
android:id="#+id/corrertView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/radioGroupOptions"
android:layout_marginRight="48dp"
android:text="#string/correct" />
</ViewFlipper>
</RelativeLayout>
</RelativeLayout>
i didnt get it that how i put another button into ViewFliper ..its confusion and generating error...
You haven't closed your ViewFlipper with </ViewFlipper>
Could this be what you are looking for,
android:id="#+id/layout"
You missed a "+" symbol while creating a id.

Can't resize a RelativeLayout inside a ScrollView to fill the whole screen

I am having a weird issue that I am not sure how to fix. I have a RelativeLayout inside a ScrollView and this scrollView has it's height set to fill_parent. So does the RelativeLayout. Still, the contents are not filling the entire screen and it's going only to the wrap_content of the last layout inside this RelativeLayout.
Here is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pontai"
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/relativeLayout3"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/relativeLayout5"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="How much points you have here:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textViewTotalPoints1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="120"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout4"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_alignLeft="#+id/relativeLayout3"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="5dp"
android:layout_toLeftOf="#+id/textView7"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Ratings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewPositivePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/textView3"
android:layout_toLeftOf="#+id/textView3"
android:src="#drawable/thumbs_up_focused" />
<TextView
android:id="#+id/textViewNegativePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_centerVertical="true"
android:layout_marginRight="3dp"
android:text="22"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textViewNegativePoints"
android:layout_alignBottom="#+id/textViewNegativePoints"
android:layout_alignLeft="#+id/textView3"
android:layout_marginLeft="3dp"
android:text="33"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/imageView2"
android:layout_toRightOf="#+id/textViewNegativePoints"
android:src="#drawable/thumbs_down_focused" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="95dp"
android:layout_height="80dp"
android:layout_alignRight="#+id/relativeLayout3"
android:layout_alignTop="#+id/relativeLayout4"
android:layout_toRightOf="#+id/textView7"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/speech_bubble" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout4"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/textViewOfferName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Offer Name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewBusinessName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:text="Business Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewBusinessAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Business Address"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewNull1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewTotalPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewNull1"
android:layout_centerHorizontal="true"
android:text="0/0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/buttonUseNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewTotalPoints"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/offer_details_use_now" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/buttonUseNow"
android:layout_marginTop="10dp"
android:text="#string/_terms_and_conditions_"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textViewTermsConditions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView2"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/relativeLayout5"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:text="e"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Anyone have ideas of how I can make the RelativeLayout2 to have the same height as the ScrollView, meaning, I want it to reach the bottom of the screen?
Thanks and regards,
Felipe
I have faced this problem before. Just Use android:fillViewport="true" in your scrollview and it will fill up the screen.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >

Categories

Resources