i want to display two buttons at the bottom of my activity screen, but each time i populate the screen with views that makes me scroll, the two buttons at the bottom of my screen disappears. when there is no need to scroll the buttons display fine.
please help
thanks.
Layout code
?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/lin_layout_list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:isScrollContainer="true"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2px"
android:layout_gravity="bottom"
>
<TableLayout
android:layout_below="#id/lin_layout_list_view"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_width ="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1">
<TableRow
android:orientation="horizontal">
<Button android:id="#+id/ws_button_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Back "
/>
<Button android:id="#+id/ws_button_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Ok "/>
</TableRow>
</TableLayout>
</RelativeLayout>
</LinearLayout>
Wrap the buttons along with the scrollable content(e.g:-Listview) in a scrollview and then display the content.
Related
I want to build an expandable/collapsible TableRow. I have two rows and I want an expandable or collapsible button (like a small 'v') on the second row. Upon clicking the button, I want to expand the 2nd row with some other views. I am very new to android development, and I am not sure how to achieve this. This is what I currently have.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4B0082">
<TableLayout
android:id="#+id/table_layout"
android:layout_width="370.0dp"
android:layout_height="350.0dp"
android:layout_centerInParent="true"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin">
<TableRow
android:background="#drawable/top_table_row_appearance">
<TextView
android:text="HNL"
android:padding="8dp"
android:textColor="#android:color/black"
android:textSize="15dp"/>
<TextView
android:text="LAS"
android:padding="8dp"
android:textColor="#android:color/black"
android:textSize="15dp"/>
</TableRow>
<TableRow
android:layout_marginBottom="5dp"
android:layout_weight=""
android:background="#drawable/tail_table_row_appearance">
<ImageView
android:id="#+id/image1"
android:src="#mipmap/ic_child_friendly_black_24dp"/>
<!--I want a collapsible button here. When I click it, this row should expand itself showing additional hidden views-->
</TableRow>
</TableLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
android:layout_alignParentBottom="true"
app:menu="#menu/navigation" />
</RelativeLayout>
I am designing a layout in which i have 3 buttons at the center of the screen and a grid view at bottom f the screen. in the grid view i am adding images. but when i am adding images the buttons are fixed at their places and after many images gridview start covering the buttons starting from bottom. is there any way i can dynamically adjust the screen when the number of image increase.
my activity.xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:andriod="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/address1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="locate yourself"
android:onClick="address"/>
<Button
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="photo"
android:onClick="takePicture"/>
<Button
android:id="#+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="place order"
android:onClick="confirm"/>
</LinearLayout>
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center">
</RelativeLayout>
I'm trying to create a custom dialog box but it's both making it as wide as the screen (minus padding) but more importantly it's adding about an inch to the top in white (the background colour is red) above the first textview. What I want is a dialog box just as big as it needs to fill the content.
If I change any layout from fill_parent to wrap_content I get the contents about the size of the image and everything else (i.e. the text) is truncated.
What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/customdialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/titledialog"
android:orientation="vertical" >
<TextView
android:id="#+id/textTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/titleback"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="24dp"
android:paddingTop="48dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<Button
android:id="#+id/buttonCustomDialogOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Close" />
I found the answer here
Android: How to create a Dialog without a title?
Apparently the top blank bit is the title of the layout and you cannot get rid of it unless you use an AlertDialog and not a Dialog.
ah, thanks for the update.
Android Dialog: Removing title bar
you can do it like this
Dialog dialog = new Dialog(context, R.style.FullHeightDialog);
(OR Try This)
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
I wanna do such a layout in android, i can't figure it out.
one button on top, one button at bottom, and a listview take the rest center area, how to make the listview take the rest area? is this possible if parent container is vertical LinearLayout?
thanks
What i have done in my project is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/task_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/tasks" />
<ListView
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/task_title"
android:layout_above="#+id/add_button">
<!-- Preview: listitem=#layout/task_list_item -->
</ListView>
<TextView
android:id="#id/android:empty"
android:text="#string/no_tasks"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:layout_below="#id/task_title"
android:layout_above="#id/add_button"/>
<Button
android:id="#id/add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="#string/plus_sign" />
<Button
android:id="#+id/remove_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/add_button"
android:text="#string/remove_task" />
</RelativeLayout>
With relative layout you can simply do it, the key layout properties are android:layout_alignParentBottom="true" , android:layout_alignParentTop="true"
I have an app that I am putting together and I have a background on it. There is a header on top and a ListView in the middle. When I have a list in the middle that isn't at least as big as the screen it just shows gray not the background of the parent layout. The weird thing is that this doesn't happen on my older phone, the background fills the whole screen even if the list doesn't. Here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the xml for HomeActivity, more information in HomeActivity.java -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/common_aboutLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg">
<!-- This is the header on the top of the home screen -->
<LinearLayout android:id="#+id/dynamicBanner"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/header"
android:layout_width="fill_parent">
<!-- This is the temp pop-up on start -->
<TextView android:text="#+id/TextView01"
android:id="#+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textColor="#FFFFFF"
android:visibility="invisible"
android:textStyle="bold"
android:typeface="sans"
android:ellipsize="end"
android:textSize="18sp"
android:gravity="center_vertical|center_horizontal">
</TextView>
</LinearLayout>
<!-- This is the layout of the list of ringtones. -->
<ListView android:id="#+id/homeListView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout android:id="#+id/adLayout"
android:layout_width="fill_parent"
android:layout_height="0dp">
<com.admob.android.ads.AdView android:id="#+id/ad"
admob:textColor="#FFFFFF"
admob:keywords="Android application"
android:layout_width="fill_parent"
android:layout_gravity="bottom|center"
admob:backgroundColor="#666666"
admob:refreshInterval="30"
android:layout_height="0dp" />
</LinearLayout>
</LinearLayout>
The TextView is just a temp thing when the window first opens.
Just looking for some help, Thanks.
put All views in RelativeLayout.then put this admob layout and add a tag to plcae this to bottom of layout
like
android:layout_alignParentBottom="true"
<LinearLayout android:id="#+id/adLayout"
android:layout_width="fill_parent"
android:layout_height="0dp">
<com.admob.android.ads.AdView android:id="#+id/ad"
admob:textColor="#FFFFFF"
admob:keywords="Android application"
android:layout_width="fill_parent"
android:layout_gravity="bottom|center"
admob:backgroundColor="#666666"
admob:refreshInterval="30"
android:layout_height="0dp" />
</LinearLayout>
and then Header part inside the relative layout
android:layout_alignParentTop="true"
and the put the ListView and
android:layout_above="#+id/adLayout"
android:layout_below=HEADERVIEW