I am new at android. I want the page with an ImageView at top of screen , 4 buttons at bottom of page and there is one frameLayout at the middle of page. I have done with a xml file for loading in FrameLayout. it contains ScrollView and 10 buttons. but when i run the program, the last two of buttons are not showing on page after scrolling page.
can anybody help me out?
main.xml:
<?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/background">
<ImageView
android:id="#+id/yellowbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/smallyelowbar"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_alignParentTop="true"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0"
android:layout_gravity="bottom"
android:layout_below="#id/yellowbar">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/topmenu"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<Button android:id="#+id/btn1"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/more_selector"/>
<Button
android:id="#+id/btn2"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/contact_selector"/>
<Button android:id="#+id/btn3"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/product_selector"/>
<Button android:id="#+id/btn4"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/introduce_selector"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
scrooll.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="#+id/btn1_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:text="#string/btn1_product"
android:textColor="#color/white"
android:textSize="10sp"/>
<Button
android:id="#+id/btn2_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn2_product"
android:layout_below="#id/btn1_product"
android:textSize="10sp"/>
<Button
android:id="#+id/btn3_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn3_product"
android:layout_below="#id/btn2_product"
android:textSize="10sp"/>
<Button
android:id="#+id/btn4_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn4_product"
android:layout_below="#id/btn3_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn5_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn5_product"
android:layout_below="#id/btn4_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn6_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn6_product"
android:layout_below="#id/btn5_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn7_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn7_product"
android:layout_below="#id/btn6_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn8_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn8_product"
android:layout_below="#id/btn7_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn9_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn9_product"
android:layout_below="#id/btn8_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn10_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn10_product"
android:layout_below="#id/btn9_product"
android:textSize="12sp"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Thanks for help.
Try giving "wrap_content" to height
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" > </ScrollView>
Add android:weightSum=4 in the last LinearLayout of first xml.
Convert RelativeLayout to LinearLayout, it will work.
Related
I am facing a problem with android layout.
I have a relative layout with a textview and an image overlapped and I would like to add two button at the bottom of the view, one close to other and that fill all the width of the view. Here below the manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:orientation="vertical"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_gravity="center"
android:longClickable="false"
android:layout_width="283dp"
android:layout_height="418dp"
android:src="#mipmap/bg_thand"
android:adjustViewBounds="false"
android:alpha="0.1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle">
<TextView
android:textSize="20sp"
android:gravity="center_horizontal"
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="#string/title_activity_record_accel_data"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/recording"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/back"/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
The layout appears in this way.
I would like that the two button appear in the same position but centered and that they fill equally the view in width.
Hope you will help me.
Can u modify your button layout impl. with the below sample and try.
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1">
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:id="#+id/back"
android:layout_weight="0.5"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"/>
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="0.5"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"/>
</LinearLayout>
Hi you can put buttons in linear layout and align parent bottom:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#mipmap/bg_thand" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="#string/title_activity_record_accel_data"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/recording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="#+id/back"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_toRightOf="#+id/back"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
check this it will help.
android:weight is what you may be looking for. Enclose the two buttons inside a linear layout and add android:weight =1 for both of them. An example would be :
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button android:id="#+id/button1"
...
android:layout_weight="1"/>
<View
android:id="#+id/space"
...
android:layout_weight=".1"/>
<Button android:id="#+id/button2"
...
android:layout_weight="1"/>
</LinearLayout>
You need to add spacer in in center bottom and align two button to that spacer like this :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
//Aligh Space in center with align to bottom
and set relation of two button to this spacer
<Space
android:layout_width="1px"
android:layout_height="1px"
android:layout_above="#+id/back"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/space"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="Back"
android:layout_gravity="center"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/accelText"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="Status"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_alignParentBottom="true"
android:layout_toStartOf="#+id/space"/>
</RelativeLayout>
Use this layout changes made with Button added inside Linear Layout and filled it with weight with android:gravity="bottom" and android:orientation="horizontal".
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#drawable/common_ic_googleplayservices" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/common_ic_googleplayservices"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="Progress"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="REcording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/back"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
I am having trouble with a scrolling ListView inside a ScrollView.I have tried the code given bellow.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linlaypromodet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearlayoutheaderpromo"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="#drawable/dairam_header2">
<Button
android:id="#+id/buttonbackhomepromodet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back_arrow"
android:layout_marginLeft="3dp"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="80dp">
<TextView
android:id="#+id/textviewheaderpromodete"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:textColor="#fff"
android:layout_marginLeft="4dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/buttonsharepromodet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="30dp"
android:layout_marginRight="10dp"
android:background="#drawable/shareicon" />
</RelativeLayout>
</LinearLayout> <ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/buttoncartpromodet"
android:layout_weight="2"
android:layout_marginTop="5dp" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="100dp" >
<com.dairam.viewpager.AutoScrollViewPager
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:minHeight="100dp"
android:layout_alignParentTop="true"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="75dp" >
<Button
android:id="#+id/buttonleftarrow"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_alignParentLeft="true"
android:background="#drawable/arrow_leftgray" />
<Button
android:id="#+id/buttonrightarrow"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:background="#drawable/arrow_rightgray" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/rellay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout android:id="#+id/toplay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<Button android:id="#+id/viewbtn"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:background="#drawable/dividergray"/>
<Button
android:id="#+id/buttoncartpromodet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="5dp"
android:background="#drawable/redicon"/>
<Button
android:id="#+id/buttonwishlistpromodet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="8dp"
android:layout_toLeftOf="#+id/buttoncartpromodet"
android:background="#drawable/greenicon" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonwishlistpromodet"
android:layout_alignBottom="#+id/buttonwishlistpromodet"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:textColor="#000"/>
<ScrollView
android:id="#+id/scrollViewdesc"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:layout_marginTop="5dp" > <ListView
android:id="#+id/textViewdescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="10dp"
>
</ListView> </ScrollView>
<Button android:id="#+id/dividerbtm"
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#drawable/dividergray"
android:layout_alignBottom="#+id/textViewdescription"
android:layout_marginTop="5dp"/>
</RelativeLayout>
<TextView
android:id="#+id/textviewsuggestion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="YOU MAY ALSO LIKE"
android:textColor="#000"
android:textSize="20sp" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="#fff" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<View android:layout_height="1dp"
android:layout_width="fill_parent"
android:background="#drawable/dividergray"
android:layout_marginTop="6dp"/>
<Button
android:id="#+id/buttonamntpromodet"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginRight="8dp"
android:textColor="#fff"
android:background="#drawable/redbox" />
<Spinner
android:id="#+id/buttonquantitypromodet"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textColor="#fff"
android:spinnerMode="dropdown"
android:gravity="center"
android:paddingLeft="10dp"
android:layout_alignParentRight="true"
android:background="#drawable/greybox2" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/buttonquantitypromodet"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="3dp"
android:text=" Quantity"
android:gravity="center"
android:textColor="#fff"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</LinearLayout>
What you're doing wrong (to my knowledge) is putting the listView inside a ScrollView. ListView by itself is inherantly scrollable, so the scrollview is not necessary.
I've had issues myself in the past where it causes neither to scroll.... perhaps that is your issue.
Also, I don't know if its just how you posted the code but you shouldn't start a layout with a button.... i believe it needs to be set inside a layout tag.
Please Remove Scroll View from above Listview Because Listvie itself scrollable.
I have a problem in aligning an button and textView. I already have an textView and button in xml and i want another set of those, just below them.
But i am not able to add it. Please have a look at it.
Here is the xml,
<?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:animateLayoutChanges="true"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
<com.aavishkaar.quikies.widget.TypedfacedTextViewxmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf" />
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light" />
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"/>
</LinearLayout>
</LinearLayout>
Try this code just change orientation in your first linear layout by default linear layout orientation is horizontal
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
<com.aavishkaar.quikies.widget.TypedfacedTextView
xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"
/>
</LinearLayout>
<com.aavishkaar.quikies.widget.TypedfacedTextView
xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"
/>
</LinearLayout>
</LinearLayout>
Add
android:orientation="vertical" in first Linear Layour.
Add
android:orientation="horizontal" in Second Linear Layour.
I hope this will work , if not ignore this answer .
I'm Not very Good at this.
I have a linear layout, and inside that I have a webview and a relative layout. I want the webview to take up all the free space and let the relative layout keep it's height wrapped on the content.
I tried multiple ways but I still couldn't get it working properly.
Could someone explain to me how I could make the webview take up all the free space and keep my relative layout at the bottom with it's content wrapped.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/titlebar_top">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/logo"
android:layout_centerHorizontal="true" android:layout_centerVertical="true">
</ImageView>
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/redarrowright"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:id="#+id/imgArticlePrevious" android:layout_marginRight="10dip">
</ImageButton>
<ImageButton android:id="#+id/imgArticleRight"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/redarrowleft"
android:layout_centerVertical="true" android:layout_toLeftOf="#+id/imgArticlePrevious"
android:layout_marginRight="10dip">
</ImageButton>
</RelativeLayout>
<TextView
android:id= "#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Le soleisl sssssssssssssssss"
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:gravity="center"
android:textStyle="bold"
android:maxLines="2">
</TextView>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Info"
android:textColor="#color/red">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="|">
</TextView>
<TextView android:id="#+id/txtDate" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="26/03/2011"
android:textColor="#color/gray">
</TextView>
</LinearLayout>
<WebView android:id="#+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" layout_weight="90" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/articlebanner"
android:layout_gravity="bottom"
android:layout_weight="10">
<ImageButton android:id="#+id/imgComment"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commenticon"
android:layout_centerVertical="true">
</ImageButton>
<Button android:id="#+id/txtCommentCount"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commentbackground"
android:layout_marginLeft="10dip" android:text="4" android:textColor="#color/white"
android:textStyle="bold" android:layout_alignTop="#+id/imgComment">
</Button>
<Button android:id="#+id/imgShare" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/buttonshare"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_marginRight="2dip" android:drawableLeft="#drawable/sharebtnicon"
android:drawablePadding="2dip" android:text="Partagez"
android:textColor="#color/white" android:textStyle="bold">
</Button>
</RelativeLayout>
Webview - Takes up all the space remaining space between other widgets located at the top and bottom
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/titlebar_top">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/logo"
android:layout_centerHorizontal="true" android:layout_centerVertical="true">
</ImageView>
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/redarrowright"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:id="#+id/imgArticlePrevious" android:layout_marginRight="10dip">
</ImageButton>
<ImageButton android:id="#+id/imgArticleRight"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/redarrowleft"
android:layout_centerVertical="true" android:layout_toLeftOf="#+id/imgArticlePrevious"
android:layout_marginRight="10dip">
</ImageButton>
</RelativeLayout>
<TextView
android:id= "#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:gravity="center"
android:textStyle="bold"
android:maxLines="2">
</TextView>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Info"
android:textColor="#color/red">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="|">
</TextView>
<TextView android:id="#+id/txtDate" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="26/03/2011"
android:textColor="#color/gray">
</TextView>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView android:id="#+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" layout_weight="1"
android:layout_above="#+id/sharebar" />
<RelativeLayout
android:id="#+id/sharebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/articlebanner"
android:layout_gravity="bottom" android:layout_alignParentBottom="true">
<ImageButton android:id="#+id/imgComment"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commenticon"
android:layout_centerVertical="true">
</ImageButton>
<Button android:id="#+id/txtCommentCount"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commentbackground"
android:layout_marginLeft="10dip" android:text="4" android:textColor="#color/white"
android:textStyle="bold" android:layout_alignTop="#+id/imgComment">
</Button>
<Button android:id="#+id/imgShare" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/buttonshare"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_marginRight="2dip" android:drawableLeft="#drawable/sharebtnicon"
android:drawablePadding="2dip" android:text="Partagez"
android:textColor="#color/white" android:textStyle="bold">
</Button>
</RelativeLayout>
</RelativeLayout>
Solved, I put it in another relative layout, aligned the bar at the bottom and set the webview above it. Worked :)
I've got an input popup that I'm displaying over my activities main view that has some edit boxes in it. When the popup is displayed the activities view stays dimmed in the background (like with an alert dialog).
The issue I'm having is that when the keyboard comes up the popup is ok, but activities view in the background is shifting up. That view should be paused and I wouldn't have thought it would be affected by the keyboard at all. Is there any way to stop this from happening?
I've tried adding android:windowSoftInputMode="adjustPan" to the activity and to the pop-up with no luck.
Here's my activity layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:background="#drawable/main_bg">
<include android:id="#+id/header" layout="#layout/common_header" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<RelativeLayout
android:id="#+id/contentLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
<include android:id="#+id/btnBar" layout="#layout/common_button_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
<LinearLayout
android:id="#+id/webLayout"
android:layout_above="#+id/btnBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/blk"
android:layout_margin="10dp">
<WebView
android:id="#+id/WebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:background="#drawable/white"
>
</WebView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
and here is my pop-up layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/light_grey" android:layout_width="wrap_content" android:minWidth="300dp">
<LinearLayout
android:id="#+id/main_inner_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/white"
android:layout_margin="3dp"
>
<TextView
android:id="#+id/enter_txt"
android:text="Enter Cup Code Below:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#color/black"
android:layout_gravity="left"
android:typeface="sans"
android:textSize="16dp"
android:layout_margin="10dp"
>
</TextView>
<RelativeLayout
android:id="#+id/code_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<EditText
android:text="12345"
android:id="#+id/CodeInputOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentLeft="true"
></EditText>
<EditText
android:text="12345"
android:id="#+id/CodeInputTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_centerHorizontal="true"
></EditText>
<EditText
android:text="12345"
android:id="#+id/CodeInputThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_alignParentRight="true"
></EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/btn_layout_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<Button
android:id="#+id/AccountBtn"
android:textStyle="bold"
android:text="My Account"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
<Button
android:id="#+id/SubmitBtn"
android:textStyle="bold"
android:text="Submit"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
</RelativeLayout>
<RelativeLayout
android:id="#+id/btn_layout_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
>
<Button
android:id="#+id/RewardsBtn"
android:textStyle="bold"
android:text="Rewards"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
<Button
android:id="#+id/CancelBtn"
android:textStyle="bold"
android:text="Cancel"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"
android:onClick="ClickHandler"
android:layout_height="40dp"
android:layout_width="130dp"
></Button>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Thanks!
Try using
android:windowSoftInputMode="adjustPan|adjustResize"
for the activity.