ListView problem - android

I have an image of some restaurant and under that some info of that restaurant. Under all of that i have some listView with some menu (what is on discount)... My problem is this: Before listView i have an textView with a description of that restaurant. It can be different sizes for different restaurants, and because of that sometimes my listView isn't showing on screen. I tried to put ScrollView, but it was bad idea... What can I do??? ANy sugestion??? Here is my code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:keepScreenOn="true">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50"
android:id="#+id/linearLayoutOne1">
<ImageView android:layout_width="0dip"
android:layout_height="wrap_content"
android:src="#drawable/marker_a"
android:id="#+id/imageView1"
android:layout_weight="1"
android:scaleType="fitStart"
android:layout_gravity="center"
>
</ImageView>
</LinearLayout>
<ScrollView
android:id="#+id/widgetOne"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="Ime restorana"
android:textSize="20sp"
android:id="#+id/textViewImeRestorana"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:background="#5E5E5E">
</TextView>
<TextView android:text=""
android:id="#+id/textViewAdresa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/daljina"
android:id="#+id/textViewDaljina"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView
android:text=""
android:id="#+id/textViewNista"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/radno_vreme_"
android:id="#+id/textViewRadnoVreme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pon_nedelja"
android:id="#+id/textViewPonSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="Nedelja"
android:id="#+id/textViewNedelja"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pozovite_nas_"
android:id="#+id/textViewPozovite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<Button android:text="Pozovi"
android:id="#+id/buttonPozovi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_weight="1">
</Button>
<TextView android:text="Opis"
android:id="#+id/textViewOpis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#5E5E5E"
android:background="#drawable/border">
</TextView>
<TextView android:text="#string/specijalna_ponuda"
android:id="#+id/textViewSpecijalnaPonuda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp">
</TextView>
<TextView android:text=""
android:id="#+id/textViewPonudeNema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textSize="14sp">
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/listViewPonuda"
android:layout_width="fill_parent"
android:smoothScrollbar="true"
android:visibility="visible"
android:layout_height="70dip"
android:textSize="14sp">
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

Placing ListView or ScrollView on another List/ScrollView doesn't work properly.
You can use ListView#addHeaderView(View view) to add the description of the restaurant. This behaves as one more row at the top of the list which doesn't need to be similar to the other rows defined in adapter.

In you xml file you used the layourt height as fill_parent in the inner layout.So that it behaves like that.
try this code
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="Vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:keepScreenOn="true">
<ImageView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:src="#drawable/marker_a"
android:id="#+id/imageView1"
android:layout_weight="1"
android:scaleType="fitStart"
android:layout_gravity="center"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Ime restorana"
android:textSize="20sp"
android:id="#+id/textViewImeRestorana"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:background="#5E5E5E">
</TextView>
<TextView android:text=""
android:id="#+id/textViewAdresa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/daljina"
android:id="#+id/textViewDaljina"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView
android:text=""
android:id="#+id/textViewNista"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/radno_vreme_"
android:id="#+id/textViewRadnoVreme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pon_nedelja"
android:id="#+id/textViewPonSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="Nedelja"
android:id="#+id/textViewNedelja"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pozovite_nas_"
android:id="#+id/textViewPozovite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<Button android:text="Pozovi"
android:id="#+id/buttonPozovi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_weight="1">
</Button>
<TextView android:text="Opis"
android:id="#+id/textViewOpis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#5E5E5E"
android:background="#drawable/border">
</TextView>
<TextView android:text="#string/specijalna_ponuda"
android:id="#+id/textViewSpecijalnaPonuda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp">
</TextView>
<TextView android:text=""
android:id="#+id/textViewPonudeNema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textSize="14sp">
</TextView>
<ListView
android:id="#+id/listViewPonuda"
android:layout_width="fill_parent"
android:smoothScrollbar="true"
android:visibility="visible"
android:layout_height="70dip"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>

Related

Want to Show Image and Text side by side in android

I am new to android development, I am building an app and on that I want to show Imageview and Textview side by side in android layout. Below code is showing textview below the imagview. Here I am using linearlayout.
In this layout I am showing some data from database.
Expected layout design:
Imageview Text1
Text2
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.example.spand.krishnasoftwares.Main2Activity">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/colorBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20px"
android:id="#+id/vly">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/gym_logo1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/ly1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise 1"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly1"
android:paddingLeft="5px"
android:paddingRight="5px"
android:id="#+id/ly2"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise Name:"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/en1"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly2"
android:id="#+id/ly3"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Speed: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/es1"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly3"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal"
android:id="#+id/ly4">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Repetition: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/erep1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep2"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep3"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly4"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal"
android:id="#+id/ly5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weight: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/ew1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Check this.. It will creates layout view hows you want.
<?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="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/vly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20px"
android:weightSum="3">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/add" />
<LinearLayout
android:id="#+id/ly"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ly1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20px"
android:text="Exercise 1"
android:textAlignment="center"
android:textAllCaps="true"
android:textSize="10dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ly2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly1"
android:orientation="horizontal"
android:paddingLeft="5px"
android:paddingRight="5px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20px"
android:layout_weight="1"
android:text="Exercise Name:" />
<TextView
android:id="#+id/en1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20px"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/ly3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly2"
android:orientation="horizontal"
android:paddingLeft="5px"
android:paddingRight="5px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:text="Speed: " />
<TextView
android:id="#+id/es1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/ly4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly3"
android:orientation="horizontal"
android:paddingLeft="5px"
android:paddingRight="5px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:text="Repetition: " />
<TextView
android:id="#+id/erep1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textDirection="ltr" />
<TextView
android:id="#+id/erep2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff" />
<TextView
android:id="#+id/erep3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/ly5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly4"
android:orientation="horizontal"
android:paddingLeft="5px"
android:paddingRight="5px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:text="Weight: " />
<TextView
android:id="#+id/ew1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textDirection="ltr" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
why don't you use drawable left?
Use drawable left in first text-view and with proper padding between drawable and text you can easily achieve what you intend.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.example.spand.krishnasoftwares.Main2Activity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise 1"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#ffffff"
android:drawableLeft="#drawable/"
android:layout_marginTop="20px"
android:textSize="10dp"/>
</android.support.constraint.ConstraintLayout>
BENEFITS:
You can save extra nesting of multiple view groups.
Lesser rendering time in case of recycler view or list view.
Recommended by Google developers resource.
you can't use ConstraintLayout in this way, follow the this code;
<LinearLayout
android:weightSum="2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
Looks like #drawable/gym_logo1 is the child of #+id/vly LinearLayout that has android:orientation="vertical". You should try making it the child of #+id/ly1
Create your layout like this it'll work for you...but remind one thing search first if you don't get solution then ask...
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/colorBackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/gym_logo1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20px"
android:layout_toRightOf="#+id/imageView"
android:id="#+id/vly">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/ly1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise 1"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly1"
android:paddingLeft="5px"
android:paddingRight="5px"
android:id="#+id/ly2"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise Name:"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/en1"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly2"
android:id="#+id/ly3"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Speed: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/es1"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly3"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal"
android:id="#+id/ly4">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Repetition: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/erep1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep2"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep3"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ly4"
android:paddingLeft="5px"
android:paddingRight="5px"
android:orientation="horizontal"
android:id="#+id/ly5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weight: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/ew1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
Change your .xml to
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/colorBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20px"
android:id="#+id/vly">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/gym_logo1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/ly1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise 1"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:textSize="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exercise Name:"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/en1"
android:textColor="#ffffff"
android:layout_marginTop="20px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Speed: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/es1"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Repetition: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/erep1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep2"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/erep3"
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weight: "
android:textColor="#ffffff"
android:layout_marginTop="10px"
android:layout_weight="1"/>
<TextView
android:id="#+id/ew1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:textColor="#ffffff"
android:textDirection="ltr" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
`

How can I make the TextView controls which contain characters "A" have the same width with text align left and control align right?

I hope the TextView controls which contain characters "A" have the same width with text align left and control align right , so I have set TextView controls which contain characters "A" with max width="150dp",
and I have set android:gravity="left" and android:layout_gravity="right"
I think I can get the result AA.png, but in fact the result is BB.png
I hope (AA.png)
Current (BB.png)
<?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="fill_parent"
android:background="#drawable/border_ui"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
android:layout_alignParentTop="true"
ads:adUnitId="#string/ad_unit_id" />
<LinearLayout
android:layout_above="#+id/linearLayout1"
android:layout_below="#+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_gravity="right"
android:layout_weight="0.5">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="A"
android:id="#+id/textView2"/>
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="AAA"
android:id="#+id/textView4"/>
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="AAAAA"
android:id="#+id/textView5"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="B"
android:id="#+id/textView3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="BBB"
android:id="#+id/textView6"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="BBBB"
android:id="#+id/textView7"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="4" >
<Button
android:id="#+id/btnReturn"
style="#style/myTextMedium"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:text="#string/BtnReturn" />
</LinearLayout>
</RelativeLayout>
You can accomplish that by adding an extra LinearLayout and removing the 150dp limitation:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
android:layout_alignParentTop="true"
ads:adUnitId="#string/ad_unit_id" />
<LinearLayout
android:layout_above="#+id/linearLayout1"
android:layout_below="#+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_weight="0.5">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="A"
android:id="#+id/textView2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="AAA"
android:id="#+id/textView4"/>
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="AAAAA"
android:id="#+id/textView5"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="B"
android:id="#+id/textView3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="BBB"
android:id="#+id/textView6"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="BBBB"
android:id="#+id/textView7"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="4" >
<Button
android:id="#+id/btnReturn"
style="#style/myTextMedium"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:text="#string/BtnReturn" />
</LinearLayout>
i guess you will use
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_gravity="right"
android:layout_weight="0.5"
android:layoutMarginLeft="20dp">
android:layoutMarginLeft="20dp"

How to align ImageView & TextView align right in a Linear Layout

I would like show my Page view header like below,
I'm using the following layout using, but the image and second textview not moving to right, its all align center.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
how I can align one image view and textview right aligned.
Check out this one and let me know if it is what you want.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#android:color/black"
android:gravity="center" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/ic_launcher"
android:layout_toLeftOf="#+id/tvCredits" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</TableRow>
</LinearLayout>
EDIT : If you want to make the same layout with easier and more efficient way, you can use this one.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/black" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/tvCredits"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
// try this way
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:gravity="center"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textColor="#fff"
android:textSize="16sp"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="right">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="right|center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
</LinearLayout>

android: layout background turns black after hiding another layout

i have activity that display some info about school, and subscribe button
when the subscribe button is pressed, it shows another layout with edittext and button to enter subscription code
no the problem, if i pressed cancel the i got black background in the middle
this is the activity layout code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:id="#+id/linearLayout"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:background="#333"
android:layout_marginBottom="10dp"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#+id/followOrgImage"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="5"
android:paddingLeft="7dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Untitled!"
android:id="#+id/titleTxt"
android:textStyle="bold"
android:textColor="#fff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="#+id/followTextDate"
android:textColor="#8B8B8B" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="#+id/followTextDesc"
android:textColor="#C4C4C4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/followTextCountry"
android:textColor="#fafafa" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="250dp"
android:layout_height="45dp"
>
<Button
android:layout_width="125dp"
android:layout_height="fill_parent"
android:text="#string/follow"
android:id="#+id/follow_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
<Button
android:layout_width="125dp"
android:layout_height="fill_parent"
android:text="#string/subscribe"
android:id="#+id/subscribe_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:visibility="gone"
android:id="#+id/subscribe_layout"
>
<EditText
android:layout_width="186dp"
android:layout_height="wrap_content"
android:id="#+id/subscribe_edit_txt"
android:layout_marginTop="3dp"
android:textColor="#fafafa"
android:singleLine="true"
android:textCursorDrawable="#drawable/cursor_color"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:hint="#string/profiles_code_hint" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="#string/addBtn"
android:id="#+id/subscribe_add_btn"
android:clickable="false"
android:layout_marginTop="5dp"
android:textColor="#ddd" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:paddingLeft="15dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:id="#+id/linearLayout2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/organization_type"
android:id="#+id/textView"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#B1B1B1"
android:layout_marginTop="4dp"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:id="#+id/linearLayout3"
android:paddingLeft="20dp"
android:paddingTop="5dp"
android:paddingRight="20dp"
android:paddingBottom="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:textColor="#444"
android:textSize="13sp"
android:id="#+id/typeTxt"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:paddingLeft="15dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"
android:id="#+id/linearLayout4"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/address"
android:id="#+id/textView2"
android:textSize="15sp"
android:enabled="true"
android:textStyle="bold" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#B1B1B1"
android:layout_marginTop="4dp"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:paddingLeft="20dp"
android:paddingTop="5dp"
android:paddingRight="20dp"
android:paddingBottom="15dp"
android:id="#+id/linearLayout5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="#444"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/addressTxt"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout5"
android:visibility="gone">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/hdnBtn"
android:visibility="gone"/>
</LinearLayout>
</RelativeLayout>
i tried to give some layouts this attributes
android:scrollingCache="false"
android:cacheColorHint="#00000000"
but it didn't solve it
any suggestions?
By seeing your requirement, There is no need of the extra tags that you have used like cacheColorHint.
Simply, show the first screen, then navigate the user to new screen on subscribe button click.
You need 2 different xml layouts for it.
Or 2nd approach could be, On click of Subscribe button, set visibility of old elements to gone and set visibility of new required elements to visible.

problem with android UI

in my app i have a application bar at the top and an tab bar at the bottom. These two are been fixed. Inbetween of them i have place a ViewFipper. Inside the view flipper i have 7 text views, one image views and an 3 image buttons.
Now my problem is i want to show all these inside the space between the application bar and the tab bar in all devices. When i check the layout with 2.7 in QVGA the last buttons get hided behind the tab bar. Whereas in 3.2 in HVGA(ADP2) there are more spaces between the last two image buttons and the tab bar. I want the contents inside the view flipper to be exactly in the middle space, there should not be any scroll view in my layout. How to get this....
Following id my layout design
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#drawable/back" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="fill_parent" android:layout_marginBottom="10dp"
android:background="#drawable/graybar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout2">
<TextView android:text="Detail" android:id="#+id/textView1"
android:textSize="24sp" android:layout_centerInParent="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:layout_width="wrap_content" android:text="Share Festival"
android:gravity="center" android:textStyle="bold"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#drawable/share">
</TextView>
</RelativeLayout>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/relativeLayout2" android:layout_above="#+id/relativeLayout4"
android:id="#+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="#+id/RLL"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_marginBottom="10dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/LL" android:gravity="center">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/imageView1"
android:src="#drawable/p144" android:layout_alignParentTop="true">
</ImageView>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_below="#+id/LL" android:layout_height="wrap_content"
android:id="#+id/RL1">
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/detailback"
android:layout_alignParentLeft="true" android:background="#drawable/left">
</ImageButton>
<TextView android:text="Detail" android:id="#+id/textView1"
android:background="#drawable/share" android:textSize="15sp"
android:layout_centerInParent="true" android:gravity="center"
android:maxLines="2" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#drawable/right">
</ImageButton>
</RelativeLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/Lq1" android:layout_below="#+id/RL1">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="date" android:id="#+id/date"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Contact : " android:id="#+id/contact"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="mail" android:id="#+id/mail"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="phone" android:id="#+id/phone"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Hollywood" android:id="#+id/address"
android:textSize="18sp" android:layout_marginTop="5dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="DeadLine : closed 2011 festival"
android:id="#+id/date" android:textSize="18sp"
android:layout_marginTop="5dp" android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Genre" android:id="#+id/genre"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="#+id/Relativelayoutadd" android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_below="#+id/Lq1" android:layout_alignBaseline="#+id/flipper">
<TextView android:text="Add to IPhone calendar" android:id="#+id/calendar"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:text="Add to favorite" android:id="#+id/addtofavorite"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
</RelativeLayout>
</ViewFlipper>
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"
android:background="#drawable/applicarion_bar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout4">
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="5dp" android:layout_height="wrap_content"
android:id="#+id/detailfestivallist" android:layout_alignParentLeft="true"
android:background="#drawable/festival_btn">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="90dp" android:layout_height="wrap_content"
android:id="#+id/detailsearch" android:layout_alignParentLeft="true"
android:background="#drawable/search_btn">
</ImageButton>
<TextView android:layout_width="wrap_content" android:text="MAR 20"
android:textSize="9sp" android:layout_marginLeft="170dp"
android:layout_height="wrap_content" android:id="#+id/detailcalendar"
android:layout_alignParentLeft="true" android:background="#drawable/calendar_btn">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_marginRight="5dp" android:layout_height="wrap_content"
android:id="#+id/detailfavorite" android:layout_alignParentRight="true"
android:background="#drawable/favorite_btn">
</ImageButton>
</RelativeLayout>
</RelativeLayout>
First, you have two different elements called android:id="#+id/date". This might give conflicts, and awkward behavior.
Secondly, the android:id="#+id/RLL" is only used to position items vertically. Therefore consider using a LinearLayout instead.
In general, I think your layout uses too much containers. I've created another layout (and replaced the drawables with colours, since i don't have the drawables) which you might use for inspiration to create a simpler, and flexible layout. As commented by Siva K, you can use the android:layout_weight="1" for the elements in the center (in the LinearLayout) to space them evenly...
Below is an example (only the viewFlipper part, the rest is unchanged)
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/relativeLayout2" android:layout_above="#+id/relativeLayout4"
android:id="#+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/RLL"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- HEADER IMAGE -->
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/imageView1"
android:src="#ff5500" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
</ImageView>
<!-- TOP -->
<TextView android:text="Detail" android:id="#+id/textView1"
android:background="#ff0022" android:textSize="15sp"
android:layout_centerInParent="true" android:gravity="center"
android:maxLines="2" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/imageView1">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/detailback"
android:layout_alignParentLeft="true" android:background="#112233"
android:layout_alignTop="#id/textView1">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#55ff22"
android:layout_alignTop="#id/textView1">
</ImageButton>
<!-- MIDDLE -->
<LinearLayout
android:id="#+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/textView1"
android:orientation="vertical"
android:layout_marginBottom="20dp">
<TextView android:text="date" android:id="#+id/date"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Contact : " android:id="#+id/contact"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="mail" android:id="#+id/mail"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="phone" android:id="#+id/phone"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Hollywood" android:id="#+id/address"
android:textSize="18sp" android:layout_marginTop="5dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="DeadLine : closed 2011 festival"
android:id="#+id/date2" android:textSize="18sp"
android:layout_marginTop="5dp" android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Genre" android:id="#+id/genre"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
</LinearLayout>
<!-- BOTTOM -->
<TextView android:text="Add to IPhone calendar" android:id="#+id/calendar"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentBottom="true">
</TextView>
<TextView android:text="Add to favorite" android:id="#+id/addtofavorite"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentBottom="true">
</TextView>
</RelativeLayout>
</ViewFlipper>
Hope this works for you.

Categories

Resources