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>
Related
I'm trying to stack two vertical LinearLayout in LinearLayout horizontally.
My code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horisontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Also everything looks as I and has conceived:
And the scheme for full understanding:
But when I compile that in VS2015 see error "String types not allowed (at 'orientation' with value 'horisontal')". Need help
Its a typo.
Change,
android:orientation="horisontal"
to
android:orientation="horizontal"
In the root use below attribute
wheightSum="10"
and in child view use wheight = "5" for each child view
Note: on base layout use android:orientation="horizontal" for horizontal display or android:orientation="vertical" for vertical display
Error in LinearLayout orientation.It should be horizontal or remove this.(By default Linear layout has horizontal orientation. )
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have two problem in ScrollView when I try to put in my xml layout code.
First problem: I can see just first item inside ListView and overviewMovie TextView text is hidden, second problem: is ScrollView just work in orientation landscape.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:padding="16dp">
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="**.DetialFragment">
<TextView
android:id="#+id/titleDetialMovie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/CadetBlue"
android:gravity="left"
android:padding="30dp"
android:textColor="#color/white"
android:textSize="40dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal">
<ImageView
android:id="#+id/postImageMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:scaleType="center"
android:src="#drawable/abc_btn_rating_star_on_mtrl_alpha" />
<TextView
android:id="#+id/dateReleaseMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp"
android:paddingLeft="18dp"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
<RatingBar
android:id="#+id/ratingMovie"
style="#style/foodRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="9"
android:stepSize="0.1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Summary"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/overviewMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Review"
android:textSize="18dp"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/fragment_detial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="**.DetialFragment">
<ListView
android:id="#+id/list_review"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></ListView>
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="List Video"
android:textSize="18dp"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/fragment_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="**.DetialFragment">
<ListView
android:id="#+id/list_video"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
></ListView>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="**.DetialFragment">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:padding="16dp">
<TextView
android:id="#+id/titleDetialMovie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/CadetBlue"
android:gravity="left"
android:padding="30dp"
android:textColor="#color/white"
android:textSize="40dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal">
<ImageView
android:id="#+id/postImageMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:scaleType="center"
android:src="#drawable/abc_btn_rating_star_on_mtrl_alpha" />
<TextView
android:id="#+id/dateReleaseMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp"
android:paddingLeft="18dp"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
<RatingBar
android:id="#+id/ratingMovie"
style="#style/foodRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="9"
android:stepSize="0.1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Summary"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/overviewMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Review"
android:textSize="18dp"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/fragment_detial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="**.DetialFragment">
<ListView
android:id="#+id/list_review"
android:layout_width="wrap_content"
android:scrollbars="vertical"
android:layout_height="wrap_content"></ListView>
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="List Video"
android:textSize="18dp"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/fragment_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="**.DetialFragment">
<ListView
android:id="#+id/list_video"
android:layout_width="wrap_content"
android:scrollbars="vertical"
android:layout_height="wrap_content"
></ListView>
</FrameLayout>
</LinearLayout>
<?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:background="#00b9e8"
android:orientation="vertical" >
<!-- <include layout="#layout/header" /> -->
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#ffffff"
android:gravity="center"
android:padding="5dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Status"
android:textColor="#0060a4"
android:textSize="#dimen/font_15dp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageView
android:id="#+id/setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/settings" />
<ImageView
android:id="#+id/searchstatus_imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.35"
android:background="#drawable/round_bg"
android:padding="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Status"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0060a4"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="0.65"
android:background="#drawable/round_bg"
android:gravity="center"
android:padding="8dp" >
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="Accepted"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0060a4"
android:textSize="20dp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="40dip"
android:layout_height="40dip"
android:paddingLeft="25dip" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp" >
<LinearLayout
android:id="#+id/linearlayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.35"
android:background="#drawable/round_bg"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Reason"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0060a4"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="0.65"
android:background="#drawable/round_bg"
android:gravity="center"
android:padding="10dp" >
<TextView
android:id="#+id/reason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0060a4"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</LinearLayot>
This is my code i want to add one Footer but i am unable to do this i dont know why this Problem is coming even i have take relative layout then also its not working please tell me how add one footer plz Help
Try this method and better to use relative layout for this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentTop="true"
android:layout_above="#+id/footer"
android:id="#+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#999"
android:layout_margin="4dp"
>
<TextView
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Content"
android:gravity="center"
android:padding="20dp"
android:textColor="#fff"
/>
</LinearLayout>
<LinearLayout
android:layout_alignParentBottom="true"
android:id="#+id/footer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FOOTER"
android:gravity="center"
android:padding="20dp"
android:textColor="#fff"
android:background="#666"
/>
</LinearLayout>
</RelativeLayout>
this will give like this .is that you want ?
EDITED to improve specifics:
Hi, my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:padding="10dp"
tools:context="${packageName}.${activityClass}" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="Select Character"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_below="#+id/textView1"
android:orientation="vertical"
android:paddingTop="10dp" >
<TextView
android:id="#+id/SelectedCharacterName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<TextView
android:id="#+id/TraitName1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trait 1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff" />
etc...
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:fillViewport="false"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Character1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#4a4a4a"
android:clickable="true"
android:gravity="center"
android:text="Character 1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
etc...
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/buttonConfirmCharacter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:text="#string/button_Confirm" />
</LinearLayout>
I am looking to make the scrollview fit the remaining space between the other elements however with this setup the scrollview doesn't seem to render at all. These settings are the result of looking for solutions and implementing weight.
An answer without java code would be preferential.
Thanks.
Here, this would works just fine
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text1" />
<TextView
android:id="#+id/SelectedCharacterName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:layout_marginTop="10dp" />
<TextView
android:id="#+id/TraitName1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trait 1" />
etc...
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Character1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="center"
android:text="Character 1" />
etc...
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/buttonConfirmCharacter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/button_Confirm" /></LinearLayout>
I want to design following design in android using Linear layout
I had written following code but not working
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:text="TextView" android:layout_weight="1" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
it gives me output like
can anyone pointout me.. where is problem???
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="dfasdfasdfasfasf" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="07 DEc" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dskfhasjkldfhadjklsfhadjklsfhajkldfhadjklsfhajklsfhajklsdfhajklsdfhajklsdfhajkldf" />
</LinearLayout>
</LinearLayout>
This will work... :)
This will work for you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:padding="5dip" >
<ImageView
android:id="#+id/icon"
android:layout_width="70px"
android:layout_height="50px"
android:layout_marginRight="3dip"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/toptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="dsggsdggfsgf"
android:textColor="#000000"
android:textSize="16px"
android:textStyle="bold" />
<TextView
android:id="#+id/datetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:maxLines="1"
android:text="1 dec 2012"
android:textColor="#cccccc"
android:textSize="12px"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:id="#+id/bottomtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdf"
android:textColor="#696969"
android:textSize="12px" />
</LinearLayout>
</LinearLayout>
I think you can use relativelayout at first level, like the following:
<relativelayout>
<imageview align to parent top, left, bottom>
<linearlayout align to parent to, right, right to image view>
<textview1/>
<textview2/>
</linearlayout>
<textview align to parent bottom, right, righto to image view, below linearlayout>
</relativelayout>
This should work. But it will be better if you use RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="TestData"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="3"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame"
android:layout_weight="2"/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hfdfhfj" android:layout_weight="2" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6 Dec 2012" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fkjfkdsnfdsnfkdsn\nmnfkfknfkdf\nfknf" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this code.it is exactly what you want.