I have listview in which I am setting six different things. And that is working awesome on normal size devices. But its gets chopped off from the last item of the single row that is Text view.
I do not understand why it is happening I have Used linear layouts. And why it is only getting chopped off in the large size devices like Samsung Tab 7" and 10"
although normal devices are showing it good.
Edit One : This is design of my Listview Row
Here is what my Layout of listview looks a like.
<?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="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:background="#drawable/box"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:weightSum="20">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:id="#+id/tv_row_customer_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/accepted_offer_text_size"
android:layout_marginTop="2dp"
android:text="Customer Name Goes Here"
android:textColor="#ffa123"
android:textSize="#dimen/accepted_offer_text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/dialog_offer_name"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Offer Name Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/mail"
android:gravity="left|center"
android:paddingLeft="5dp"
android:text="Email Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_phone_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/call"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Phone Number Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/pin"
android:ellipsize="end"
android:gravity="left|center"
android:minLines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="Address Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_c_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/cofin"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text=" Brand Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/clock"
android:paddingLeft="5dp"
android:text="Start-End Time Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" "
android:textColor="#AAAAAA" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_weight="15"
android:orientation="horizontal"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:gravity="right"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="3">
<TextView
android:id="#+id/tv_row_total_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/no_of_persons"
android:gravity="center"
android:text="aa" />
<TextView
android:id="#+id/tv_row_total_acceptors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/acceptors"
android:gravity="center"
android:text="aa" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/calander_upper"
android:gravity="center">
<TextView
android:id="#+id/tv_row_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:gravity="center"
android:hint="aa"
android:paddingTop="2dp"
android:textSize="#dimen/dialog_accept_offer_tvcontent_size" />
</LinearLayout>
<TextView
android:id="#+id/tv_row_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_row_month"
android:layout_alignStart="#+id/tv_row_month"
android:layout_below="#+id/tv_row_month"
android:layout_gravity="center"
android:background="#drawable/calander_lower"
android:gravity="center"
android:padding="0dp"
android:text="aa"
android:textSize="#dimen/dialog_accept_offer_tvcontent_size" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I added the Last textview empty so that it can be gets chopped off. but has no effect. I have debug my code and saw that in adapter the last textview is truly initialized and then the last textview gets the data. but its still not visible or chopped off.
Please help me just this minor problem is keeping me away to complete the app.
try to add "scrollView" so if your layout is not fit on any device it will scroll otherwise use weight in your layout so it will adjust according to each screen size. if you not understand you can ask question in comments, I will explain about that.
<?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="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:weightSum="20">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:id="#+id/tv_row_customer_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="Customer Name Goes Here"
android:textColor="#ffa123" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Offer Name Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center"
android:paddingLeft="5dp"
android:text="Email Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_phone_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text="Phone Number Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="left|center"
android:minLines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="Address Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_c_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:paddingLeft="5dp"
android:text=" Brand Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:id="#+id/row_offer_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Start-End Time Goes here"
android:textColor="#AAAAAA" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:orientation="horizontal"
android:paddingLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text=" "
android:textColor="#AAAAAA" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_weight="15"
android:orientation="horizontal"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:gravity="right"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="3">
<TextView
android:id="#+id/tv_row_total_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="aa" />
<TextView
android:id="#+id/tv_row_total_acceptors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="aa" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/tv_row_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:gravity="center"
android:hint="aa"
android:paddingTop="2dp" />
</LinearLayout>
<TextView
android:id="#+id/tv_row_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_row_month"
android:layout_alignStart="#+id/tv_row_month"
android:layout_below="#+id/tv_row_month"
android:layout_gravity="center"
android:gravity="center"
android:padding="0dp"
android:text="aa" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I changed something
Related
Hi, I make application with this Image.
I want place the text on red dot points at lines left side and right side.
So I place the text on point, but when I change the device Galaxy S6 to S8,
text placement depart from lines.
I seperate the lines and put weight on it, but still out.
How I can place the text on that image in variable device?
Please help me.
This is my layout.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="#drawable/nursecategory"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!--first line-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="32dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
android:textColor="#color/colorCategory"
android:textStyle="bold"
android:layout_alignParentRight="true"
/>
<TextView
android:id="#+id/nursetree_textview_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"/>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
android:textColor="#color/colorCategory"
android:textStyle="bold" />
<TextView
android:id="#+id/nursetree_textview_Age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"
/>
</LinearLayout>
</LinearLayout>
<!--second line-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="24dp"
>
<!--Name-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#color/colorCategory"
android:textStyle="bold" />
<TextView
android:id="#+id/nursetree_textview_Agency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"
/>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<!--width-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Width"
android:textColor="#color/colorCategory"
android:textStyle="bold" />
<TextView
android:id="#+id/nursetree_textview_Width"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"
/>
</LinearLayout>
</LinearLayout>
<!--third line-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="26dp"
>
<!--place-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Place"
android:textColor="#color/colorCategory"
android:textStyle="bold" />
<TextView
android:id="#+id/nursetree_textview_Place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"
/>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<!--heigth-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Height"
android:textColor="#color/colorCategory"
android:textStyle="bold" />
<TextView
android:id="#+id/nursetree_textview_Height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:textAlignment="center"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
use Relativelayout as parent layout then try to design your view.
in Relaytivelayout we can add layouts as tray. and it easily to handle.
also read about Relativlayout.
In my application screen i'm using table layout.in the table row i have two textview.The width of second textview always going out of screen width.I tried wrap_content,match_parent but not getting how to resolve this.How can i set width to device screen layout width?
xml code-
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/even" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<TableLayout
android:id="#+id/tableLayoutDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/namerow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
>
<TextView
android:id="#+id/nameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Name" />
<TextView
android:id="#+id/dname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:background="#android:color/black"
android:text="Name :"
android:textColor="#808080" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
Even after giving 100dp width to TextView its going outof screen
In your case column #0 is OK, so you just have to enable shrink (and stretch too if you like) for column #1:
<TableLayout ...
android:shrinkColumns="1"
android:stretchColumns="1" >
You can have a full explanation in the main documentation:
https://developer.android.com/reference/android/widget/TableLayout.html
Best regards
It may be Android Graphical layout issue. I checked your code in Android View Design. The TextView letters not going Beyond the layout. If you have doubt Set the BackGround to the Text view and see what happened?
use this code : work perfect(replace your code with this and modify as your choice)
<?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="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/include1"
android:layout_marginTop="20dp"
android:gravity="top"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="30dp"
android:orientation="horizontal"
android:weightSum="100" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Name"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvfullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text="sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Birthday"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvbirth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Gender"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvgender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Mobile Number"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvmobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Email Id"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text="sjdhgvfkasvsjdgfjsgdfjhgskdjfgakjsgdflaghdfljashdgfljadgsfjahg"
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Location"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvlocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="City"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvcity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
see this image :
Basically it's a page of text and pics with ads at the bottom. It works fine on smaller devices like phones, but on larger like tablets there is a problem....more of a user dislike thing.
If the content of page is small then ads, which comes correctly at the end of content actually comes in the middle of the screen.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/vnaslov"
android:layout_alignParentLeft="true"
android:layout_below="#+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginLeft="7dp"
android:gravity="left"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="#+id/vautor"
android:layout_below="#+id/vnaslov"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
/>
<TextView
android:id="#+id/vdatum"
android:layout_toRightOf="#+id/vautor"
android:layout_below="#+id/vnaslov"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
/>
<TextView
android:id="#+id/vlid"
android:layout_below="#+id/vdatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left"
android:layout_marginLeft="7dp"
android:textSize="16sp"
android:textStyle="bold"
/>
<com.loopj.android.image.SmartImageView
android:id="#+id/vslika"
android:layout_below="#+id/vlid"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_margin="5dp"
/>
<TextView
android:id="#+id/vtijelo"
android:layout_below="#+id/vslika"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_marginLeft="7dp"
android:textSize="16sp" />
<Button
android:id="#+id/videobutton"
android:layout_below="#+id/vtijelo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/dugme_video"/>
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<com.google.ads.doubleclick.DfpAdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="xxxxxxxxxxxxxxxxxxxxxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
</ScrollView>
It works if it's simple like this...
<?xml version="1.0" encoding="utf-8"?>
<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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/wrap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left"
android:text="TextView"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >
<Button
android:id="#+id/but1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="But1" >
</Button>
<Button
android:id="#+id/but2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="But2" >
</Button>
</LinearLayout>
</LinearLayout>
</ScrollView>`
But not if it's filled with my content like the above in my question. First linearlayout with content up to the ad, and second with just the ad...
How would the content inside linearlayout be a problem?
Why?
The trick is to use layout_weight="1" and fillViewport="true" on the ScrollView.
This should do the trick:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativemain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/wrap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
//put your content here
</LinearLayout>
<LinearLayout
android:id="#+id/myadv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
//this is your advertisement
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
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.
There is a list view and other text views in my screen.
I want to show the list in whole the screen and other elements in the bottom of the list.
Below is the code I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradients"
android:orientation="vertical"
android:paddingBottom="8dip"
android:paddingTop="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:gravity="center"
android:text="#string/shopping_cart"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:background="#color/white"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="#+id/purchase_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/requisitioner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/purchase_order"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/image"
android:src="#drawable/shopping_cart" />
</RelativeLayout>
<TextView
android:id="#+id/products_and_services"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/products_and_services"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/lr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.12" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/pagingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lr1"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<TextView
android:id="#+id/note_to_approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/note_to_approver"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="#color/white"
android:maxLines="10"
android:padding="5dp"
android:text="hijnjn"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<Button
android:id="#+id/approvers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/options_menu"
android:drawableRight="#drawable/arrow_right"
android:gravity="left|center"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#layout/btn_background" >
<Button
android:id="#+id/release_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#drawable/btn_blue"
android:text="Approve(1)/Reject(0)"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.
Please help me to do this.
You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.