Android TabWidget different xml files for different tabs - android

I want to implement tabwidget with several tabs, each one of them represents data from single data source which can change dynamicaly, so i cant use several activities, because as far as i understand Activity is more like an application which is not exists while its hidden.
So ive created tabwidget like this:
<ScrollView android:id ="#+id/settings_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
<ScrollView android:id="#+id/maps_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
<EditText android:id="#+id/statistics_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:singleLine="false"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip">
</EditText>
<RelativeLayout android:id="#+id/about_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="#55ff0000"
android:src="#drawable/main"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/appname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:layout_below="#id/icon"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/appname"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/site"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_site"
android:layout_below="#id/version"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_copyright"
android:layout_below="#id/site"
android:layout_centerInParent="true"/>
</RelativeLayout>
<RelativeLayout android:id ="#+id/gatewaylist_view"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
>
<LinearLayout
android:id="#+id/bottom_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!--Put whatever view item you want here -->
<Button android:text="Add Gateway"
android:id="#+id/BtnToClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</Button>
</LinearLayout>
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_above="#id/bottom_view"
/>
</RelativeLayout>
<ScrollView android:id="#+id/gatewayparams_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="#+id/addressLabels"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4">
<TextView android:id="#+id/lblIP"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/hostLabel"
android:layout_weight="3"/>
<TextView android:id="#+id/lblPort"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/portLabel"
android:layout_toRightOf="#id/lblIP"
android:layout_alignParentRight="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:id="#+id/addressEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/addressLabels">
<EditText android:id="#+id/edtHost"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_alignParentLeft="true"
android:inputType="text"
android:text="192.168.1.141"
android:layout_weight="3"/>
<EditText android:id="#+id/edtPort"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="number"
android:text="9988"
android:layout_alignParentRight="true"
android:layout_weight="1"
/>
</LinearLayout>
<CheckBox android:id="#+id/chkUseProxy"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:text="#string/useProxyLabel"
android:layout_weight="1"
android:layout_below="#id/addressEditBoxes"/>
<LinearLayout android:id="#+id/proxyLables"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/chkUseProxy">
<TextView android:id="#+id/lblProxyIP"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/hostLabel"
android:layout_weight="3"/>
<TextView android:id="#+id/lblProxyPort"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/portLabel"
android:layout_toRightOf="#id/lblProxyIP"
android:layout_alignParentRight="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:id="#+id/proxyEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/proxyLables">
<EditText android:id="#+id/edtProxyHost"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_alignParentLeft="true"
android:inputType="text"
android:text="192.168.1.141"
android:layout_weight="3"/>
<EditText android:id="#+id/edtProxyPort"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="number"
android:text="9988"
android:layout_alignParentRight="true"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout android:id="#+id/encryptionLine"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/proxyEditBoxes">
<TextView android:id="#+id/lblEncryption"
android:text="##string/encryptiontype"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
<Spinner android:id="#+id/spinnerenctype"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="#string/encryptiontype"
android:layout_weight ="2"
/>
</LinearLayout>
<LinearLayout android:id="#+id/usernameLabels"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/encryptionLine">
<TextView android:id="#+id/txtUName"
android:text="#string/usernameLabel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
<TextView android:id="#+id/txtPassword"
android:text="#string/passwordLabel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
</LinearLayout>
<LinearLayout android:id="#+id/usernameEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/usernameLabels">
<EditText android:id="#+id/edtUsername"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="text"
android:text="devdev"
android:layout_weight="2"
/>
<EditText android:id="#+id/edtPassword"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="textPassword"
android:text="devdev"
android:layout_weight="2"
/>
</LinearLayout>
<Button android:layout_height="wrap_content"
android:text="#string/connect"
android:id="#+id/btnConnect"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_below="#id/usernameEditBoxes"/>
</RelativeLayout>
</ScrollView>
<LinearLayout android:id="#+id/videofield_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>>
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="0"/>
</LinearLayout>
and i initialize my application like this
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
tabHost.addTab(tabHost.newTabSpec("tab_gatewaylist").setIndicator("",res.getDrawable(R.drawable.ic_tab_favorites)).setContent(R.id.gatewaylist_view));
tabHost.addTab(tabHost.newTabSpec("tab_gatewayparams").setIndicator("",res.getDrawable(R.drawable.ic_tab_gatewayparams)).setContent(R.id.gatewayparams_view));
tabHost.addTab(tabHost.newTabSpec("tab_videofield").setIndicator("",res.getDrawable(R.drawable.ic_tab_videofield)).setContent(R.id.videofield_view));
tabHost.addTab(tabHost.newTabSpec("tab_maps").setIndicator("",res.getDrawable(R.drawable.ic_tab_maps)).setContent(R.id.maps_view));
tabHost.addTab(tabHost.newTabSpec("tab_statistics").setIndicator("",res.getDrawable(R.drawable.ic_tab_statistics)).setContent(R.id.statistics_view));
tabHost.addTab(tabHost.newTabSpec("tab_settings").setIndicator("",res.getDrawable(R.drawable.ic_tab_settings)).setContent(R.id.settings_view));
tabHost.addTab(tabHost.newTabSpec("tab_about").setIndicator("",res.getDrawable(R.drawable.ic_tab_about)).setContent(R.id.about_view));
tabHost.setCurrentTab(0);
its works ok , but i wonder if i can separate definitions fro different tabs into separate xml files.
Ive tried to do this but application crashes while trying to add corresponding tab.
Thanks in advance.

Have you tried using the <include /> element? http://developer.android.com/resources/articles/layout-tricks-reuse.html
this way you can put the single xml definitions in different files and include them in the main one.

Related

Make FrameLayout element scrollable

I am working on adapting an app which was designed for a larger vertical screen dimension (1200px) to a device with a smaller size (vertical=800px). I've managed to get things displaying properly by editing the layout XML files--except for one thing. As you can see, the crossword puzzle is cut off at the bottom. Its original dimensions in the layout were 570x570px. At that size, the lower part of the puzzle ended up peeking out from behind the keyboard.
After resizing both the keyboard and the clue drop-down at the top of the screen so they work properly, I'm left with a vertical space of 390px for the puzzle. Absent any other ideas, I've been trying to implement scrolling in that FrameLayout, following several examples such as Scrollable FrameLayout.
I can't seem to get it to work. My knowledge of layout is sketchy. Can anyone suggest a solution or a different approach?
(the puzzle layout on the screen is given in line 6)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="bottom|center" android:orientation="vertical" android:background="#color/root_background" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout android:gravity="top|center" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<FrameLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/field_container" android:paddingTop="160.0px" android:layout_width="600.0px" android:layout_height="wrap_content">
<com.encore.crossword.view.CrosswordView android:layout_gravity="top|center" android:id="#id/crosswordView" android:layout_width="570.0px" android:layout_height="390.0px" />
<LinearLayout android:gravity="center" android:id="#id/difficulty_layout" android:paddingTop="146.0px" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_gravity="center" android:orientation="vertical" android:background="#drawable/c_dialog_box" android:paddingLeft="30.0px" android:paddingTop="30.0px" android:paddingRight="30.0px" android:paddingBottom="20.0px" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/DialogHeader" android:gravity="center" android:id="#id/TextViewGameOver" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Game Difficulty" />
<RadioGroup android:gravity="left|center" android:orientation="vertical" android:id="#id/RadioGroupDifficulty" android:paddingTop="6.0px" android:paddingBottom="6.0px" android:layout_width="fill_parent" android:layout_height="wrap_content">
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonEasy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:button="#drawable/sudoku_radio_button" android:text="#string/easy" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/medium" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonHard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/hard" android:width="160.0px" />
<RadioButton android:textAppearance="#style/ButtonTextMain" android:textColor="#color/button_radio" android:id="#id/RadioButtonExtreme" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="#drawable/sudoku_radio_button" android:text="#string/themeless" android:width="160.0px" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/clue_container" android:background="#drawable/cross_top_dialog_box" android:paddingLeft="5.0px" android:paddingRight="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/mini_clue_container" android:paddingLeft="5.0px" android:paddingRight="5.0px" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<LinearLayout android:id="#id/ClueTop1" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/ClueInfoText" android:id="#id/TextViewClueWordNumber1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
<TextView android:textAppearance="#style/ClueInfoText" android:gravity="right" android:id="#id/TextViewClueWordLength1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueText" android:id="#id/TextViewClue1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="" android:lines="2" />
<LinearLayout android:id="#id/ClueTop2" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="#style/ClueInfoText" android:id="#id/TextViewClueWordNumber2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
<TextView android:textAppearance="#style/ClueInfoText" android:gravity="right" android:id="#id/TextViewClueWordLength2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueText" android:id="#id/TextViewClue2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="" android:lines="2" />
</LinearLayout>
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_container" android:paddingLeft="0.0px" android:paddingRight="0.0px" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<TextView android:textAppearance="#style/ClueTextBold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="ACROSS" />
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_across_container" android:background="#drawable/c_dialog_box" android:paddingTop="17.0px" android:paddingBottom="17.0px" android:layout_width="fill_parent" android:layout_height="200.0px">
<ListView android:scrollbarStyle="outsideOverlay" android:id="#id/big_clue_across_list" android:paddingLeft="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<TextView android:textAppearance="#style/ClueTextBold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0px" android:text="DOWN" />
<LinearLayout android:gravity="top|center" android:orientation="vertical" android:id="#id/big_clue_down_container" android:background="#drawable/c_dialog_box" android:paddingTop="17.0px" android:paddingBottom="17.0px" android:layout_width="fill_parent" android:layout_height="200.0px">
<ListView android:id="#id/big_clue_down_list" android:paddingLeft="5.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView android:id="#id/ClueContainerArrow" android:background="#drawable/cross_down_arrow" android:layout_width="30.0px" android:layout_height="20.0px" android:layout_marginBottom="10.0px" android:layout_weight="1.0" />
</LinearLayout>
<LinearLayout android:gravity="bottom" android:layout_gravity="bottom|left|center" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<include android:id="#id/bottom_layout" android:layout_width="fill_parent" android:layout_height="160.0px" layout="#layout/bottom_layout" />
</LinearLayout>
<include android:id="#id/bottom_menu" android:layout_width="fill_parent" android:layout_height="fill_parent" layout="#layout/bottom_menu" />
</FrameLayout>
<LinearLayout android:gravity="center" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="50.0dip">
<LinearLayout android:gravity="center" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0">
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/GameButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2.0dip" android:layout_marginRight="0.0dip" android:text="Game" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/LastWordButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0.0dip" android:layout_marginRight="0.0dip" android:text="Prev Word" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/NextWordButton" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2.0dip" android:layout_marginRight="0.0dip" android:text="Next Word" android:layout_weight="1.0" />
<ImageView android:id="#id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="#drawable/footer_line_divider" />
<Button android:textAppearance="#style/ButtonText" android:textColor="#color/solid_white" android:id="#id/KeyboardButtonHint" android:background="#drawable/btn_footer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0.0dip" android:layout_marginRight="0.0dip" android:text="Hint" android:layout_weight="1.0" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

How to add time slot in recyclerview android

I have recyclerview a and all times will be displayed. I want to display slot type. should i use any library to code layout like that? or we can do in our xml itself.
please someone suggest me
activity_booking_calender.xml
<?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="#color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_large"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="Select Date & Time"
android:textColor="#color/black_updated"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/startdate_enddate_text_margin_top"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/relative_start_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_gravity="start|center"
android:gravity="start|center"
android:orientation="vertical"
android:layout_alignParentLeft="true">
<TextView
android:layout_marginLeft="20dp"
android:id="#+id/txt_start_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="#dimen/startdate_enddate_text_margin_bottom"
android:fontFamily="#font/inter_regular"
android:gravity="center"
android:text="START TIME"
android:textColor="#color/text_grey"
android:textSize="#dimen/startdate_enddate_text"
android:textStyle="bold" />
<LinearLayout
android:layout_marginLeft="20dp"
android:id="#+id/linear_start_date"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_start_date"
android:background="#drawable/btn_grey_background_no_stroke"
android:orientation="horizontal"
android:paddingTop="#dimen/motorcycle_date_text_top"
android:paddingBottom="#dimen/motorcycle_date_text_bottom">
<ImageView
android:layout_width="#dimen/motorcycle_date_icon_width"
android:layout_height="#dimen/motorcycle_date_icon_height"
android:layout_gravity="center"
android:layout_marginStart="#dimen/motorcycle_date_icon_start"
android:src="#drawable/ic_calendar_white"
android:layout_marginLeft="#dimen/motorcycle_date_icon_start" />
<TextView
android:id="#+id/txt_select_from_date"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="#dimen/motorcycle_date_text_start"
android:layout_marginEnd="#dimen/motorcycle_date_text_end"
android:fontFamily="#font/inter_regular"
android:gravity="center"
android:lineSpacingExtra="14.0sp"
android:text=""
android:textColor="#ffffffff"
android:textSize="#dimen/motorcycle_date_text"
android:layout_marginRight="#dimen/motorcycle_date_text_end"
android:layout_marginLeft="#dimen/motorcycle_date_text_start" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relative_end_date"
android:layout_width="wrap_content"
android:clickable="true"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:layout_gravity="end|center"
android:gravity="end|center"
android:orientation="vertical">
<TextView
android:id="#+id/txt_end_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="#dimen/startdate_enddate_text_margin_bottom"
android:fontFamily="#font/inter_regular"
android:gravity="center"
android:text="END TIME"
android:textColor="#color/text_grey"
android:textSize="#dimen/startdate_enddate_text"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_end_date"
android:background="#drawable/btn_grey_background_no_stroke"
android:orientation="horizontal"
android:paddingTop="#dimen/motorcycle_date_text_top"
android:paddingBottom="#dimen/motorcycle_date_text_bottom">
<ImageView
android:layout_width="#dimen/motorcycle_date_icon_width"
android:layout_height="#dimen/motorcycle_date_icon_height"
android:layout_gravity="center"
android:layout_marginStart="#dimen/motorcycle_date_icon_start"
android:src="#drawable/ic_calendar_white"
android:layout_marginLeft="#dimen/motorcycle_date_icon_start" />
<TextView
android:id="#+id/txt_to_date"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="#dimen/motorcycle_date_text_start"
android:layout_marginEnd="#dimen/motorcycle_date_text_end"
android:fontFamily="#font/inter_regular"
android:gravity="center"
android:lineSpacingExtra="14.0sp"
android:text=""
android:textColor="#ffffffff"
android:textSize="#dimen/motorcycle_date_text"
android:layout_marginLeft="#dimen/motorcycle_date_text_start"
android:layout_marginRight="#dimen/motorcycle_date_text_end" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="#+id/txt_time_select"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:gravity="center"
android:lineSpacingExtra="14.0sp"
android:padding="7.0dip"
android:text="Please Select the Minimum booking of 2 hours"
android:textAlignment="center"
android:textColor="#ff4e44d8"
android:textSize="14dp"
/>
<com.prolificinteractive.materialcalendarview.MaterialCalendarView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/calendarView"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_below="#+id/linear_time_type"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_margin="#dimen/margin_small"
android:layout_weight="0.5"
app:mcv_allowClickDaysOutsideCurrentMonth="true"
app:mcv_arrowColor="#7EA2FA"
app:mcv_selectionColor="#ff4e44d8" />
<View
android:id="#+id/divider"
android:layout_width="fill_parent"
android:layout_height="1.0dip"
android:layout_below="#+id/calendarView"
android:background="#color/divider" />
<RelativeLayout
android:id="#+id/relative_list_time_slots"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_below="#+id/divider"
android:layout_weight="0.5">
<LinearLayout
android:id="#+id/linear_progress_wave"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/txt_pick_drop_RR"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt_pick_up_drop"
android:text="Select Pick Up Time"
android:gravity="center"
android:textColor="#ff4e44d8"
android:textSize="16dp"
android:fontFamily="#font/inter_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TextView>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_below="#+id/txt_pick_drop_RR"
android:id="#+id/recyclerView_timeSlots"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="#dimen/margin_small"
android:layout_marginTop="#dimen/margin_small"
android:layout_marginEnd="#dimen/margin_small"
android:layout_marginBottom="50.0dip"
android:scrollbars="horizontal"
android:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView_timeSlots_next"
android:layout_below="#+id/txt_pick_drop_RR"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="#dimen/margin_small"
android:layout_marginTop="#dimen/margin_small"
android:layout_marginEnd="#dimen/margin_small"
android:layout_marginBottom="50.0dip"
android:scrollbars="horizontal"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/layout_actionbtns"
android:layout_margin="5.0dip"
android:gravity="bottom|center|right"
android:text="Indian Standard Time"
android:textColor="#color/light_gray"
android:textSize="10.0dip" />
<LinearLayout
android:id="#+id/layout_actionbtns"
android:layout_width="fill_parent"
android:layout_height="#dimen/common_btn_height"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<LinearLayout
android:layout_marginLeft="10dp"
android:id="#+id/btn_cancel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="#drawable/ripple_next_button"
android:clickable="true"
android:foreground="#drawable/ic_ripple_white"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center">
<ImageView
android:layout_width="17.0dip"
android:layout_height="17.0dip"
android:layout_gravity="center"
android:src="#drawable/ic_wrong" />
</LinearLayout>
<TextView
android:id="#+id/txt_cancel"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginLeft="10.0dip"
android:gravity="center"
android:text="Cancel"
android:textColor="#color/white"
android:textSize="18.0dip"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="10.0dip"
android:layout_height="fill_parent"
android:background="#color/white" />
<LinearLayout
android:layout_marginRight="10dp"
android:id="#+id/btn_done"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="#drawable/ripple_next_button"
android:clickable="true"
android:foreground="#drawable/ic_ripple_white"
android:focusable="true"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center">
<ImageView
android:layout_width="20.0dip"
android:layout_height="20.0dip"
android:layout_gravity="center"
android:src="#drawable/ic_tick" />
</LinearLayout>
<TextView
android:id="#+id/txt_done"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginLeft="10.0dip"
android:layout_marginRight="16.0dip"
android:fontFamily="#font/inter_medium"
android:gravity="center"
android:minHeight="0.0dip"
android:paddingStart="10.0dip"
android:paddingEnd="10.0dip"
android:text="NEXT"
android:textColor="#color/white"
android:textSize="16.0sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Here my Recycler view xml file. i guess we have to modify here to get layout like time slots.
but not sure how to make.
time_slot_layout.xml
<?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:background="?android:attr/selectableItemBackground"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:textAlignment="center"
android:textSize="20dp"
android:id="#+id/time_slot"
android:layout_height="35dp">
</TextView>
It's up to UX you want to achieve. Plus you don't need any external library to achieve this UX.
In this case, you can use the default Number Picker.
In XMX :
<NumberPicker
android:id="#+id/slot_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
In Acivity :
private NumberPicker picker1;
#Override.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
picker1 = findViewById(R.id.numberpicker_main_picker);
}
A NumberPicker takes an array of Strings as its values. First, create an instance variable of a string array, then initialize the array with your desired values.
private String[] pickerVals;
pickerVals = new String[] {"slot 1","slot 2","slot 3","slot 4","slot 5"}
picker1.setDisplayedValues(pickerVals);
Number Picker
Refered from this Example
You may make use of Android native widget - NumberPicker. This allows you to pick a number from a predefined range.
https://stackoverflow.com/a/39662187/5742882
For dynamic updation,
take a gist of https://github.com/drawers/SpinnerDatePicker.
This also makes use of NumberPicker with proper date formattings.

How I can put "Imagenview" under all the elements?

Hi, I commented that I have this layout and if you can see there is a line on the right which should go below the text
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_promocion_item0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#363636"
android:padding="10dip" >
<LinearLayout
android:id="#+id/contenido"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<LinearLayout
android:id="#+id/contenido_Nombre"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:orientation="horizontal"
>
<TextView
android:id="#+id/nombre_promo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Vodka + Nectar"
android:textColor="#ffffff"
android:textSize="25sp"
android:tag="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/contenido_precio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:orientation="horizontal" >
<ImageView
android:id="#+id/separador_lateral"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:src="#drawable/vertical"
android:layout_gravity="left"/>
<TextView
android:id="#+id/precio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$2200"
android:textColor="#ffffff"
android:textSize="24dp"
/>
</LinearLayout>
<ImageView
android:id="#+id/separador"
android:layout_width="0dp"
android:layout_height="19dp"
android:layout_weight=".50"
android:src="#drawable/divierblanco"
android:layout_alignParentLeft="true"/>
</LinearLayout>
</LinearLayout>
.. so is something like:
NAME: PRICE
I can not locate the image below the text .... Can you help me?
You have way too many nested LinearLayouts, IMHO, which can be bad for performance and decrease readability. I would use a RelativeLayout and 1 nested LinearLayout
<RelativeLayout
...>
<LinearLayout
android:id="#+id/someId"
....
<TextView
...>
<ImageView
...>
<TextView
...>
</LinearLayout>
<ImageView
android:layout_below="id/someId"
...>
Something like this should work.
Alternatively if this doesn't work for you, then placing that ImageVIew outside of the first child LinearLayout should also work
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_promocion_item0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#363636"
android:padding="10dip" >
<LinearLayout
android:id="#+id/contenido"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/contenido_Nombre"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:orientation="horizontal" >
<TextView
android:id="#+id/nombre_promo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Vodka + Nectar"
android:textColor="#ffffff"
android:textSize="25sp"
android:tag="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/contenido_precio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:orientation="horizontal" >
<ImageView
android:id="#+id/separador_lateral"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:src="#drawable/vertical"
android:layout_gravity="left"/>
<TextView
android:id="#+id/precio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$2200"
android:textColor="#ffffff"
android:textSize="24dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/separador"
android:layout_width="0dp"
android:layout_height="19dp"
android:layout_weight=".50"
android:src="#drawable/divierblanco"
android:layout_alignParentLeft="true"/> // this doesn't do anything in a LinearLayout
</LinearLayout>
Your imageView (with the id separador) is inside a linearLayout with an orientation set to "horizontal". Move the imageView to the outermost linearlayout like so:
EDIT: The xml that's displayed below is completely different than what I typed in my answer. What's up with that? Regardless, move the imageView down an element.
<LinearLayout
android:id="#+id/contenido"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/contenido_Nombre"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:orientation="horizontal" >
<TextView
android:id="#+id/nombre_promo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="bold"
android:text="Vodka + Nectar"
android:textColor="#ffffff"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/contenido_precio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:orientation="horizontal" >
<ImageView
android:id="#+id/separador_lateral"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="left"
android:src="#drawable/vertical" />
<TextView
android:id="#+id/precio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$2200"
android:textColor="#ffffff"
android:textSize="24dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/separador"
android:layout_width="0dp"
android:layout_height="19dp"
android:layout_alignParentLeft="true"
android:layout_weight=".50"
android:src="#drawable/divierblanco" /></LinearLayout>

ListView with button at the bottom in Activity with fixed header and footer

I am developing an Android Application and I have an Activity that looks like this. I have a header and a footer that have fixed positions, and a ListView with clickable items in the middle. Below the ListView, I have a button.
It is working when I have a few items, but as I add more items, the button begins to disappear, like this.
When I have more items in that list that can be shown in the page, I have a scroll in the list. If I scroll down like this I can see all the items in the list, but the button is hidden.
I have had a lot of problems before trying to add a ListView inside a ScrollView, so I know it doesn't work. As I am new in Android development, perhaps my XML layout files are a bit confusing, but I have a parent LinearLayout with two RelativeLayouts inside, one for the header and one for the middle and footer. The XML is something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/background"
android:gravity="center_vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="#string/baseTitle"
android:textColor="#FFFFFF"
android:layout_centerVertical="true"
android:textSize="18dp"
android:textStyle="bold"/>
<Button
android:id="#+id/buttonHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#drawable/button_help"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="fill_vertical">
<LinearLayout
android:id="#+id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:background="#bdbdbd"
android:layout_alignParentBottom="true">
<RelativeLayout
android:id="#+id/bottomButtomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<Button
android:id="#+id/myGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/myGroups"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_meus_grupos"/>
<Button
android:id="#+id/createGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:text="#string/createGroups"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_criar_grupos"/>
<Button
android:id="#+id/configurations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="#string/configurations"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_configuracoes"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_above="#id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/listContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/searchBarLayout"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:background="#ffffff"
android:gravity="center_vertical"
android:clickable="true"
>
<TextView
android:id="#+id/myGroupsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/myGroups"
android:layout_centerInParent="true"
android:textColor="#bdbdbd"
android:textSize="16dp"
android:textStyle="bold"
/>
<ImageView
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_search" />
</RelativeLayout>
<View android:layout_height="2dip"
android:layout_width="wrap_content"
android:background="#cccccc"
/>
<ListView android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:cacheColorHint="#000000"
/>
<Button
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="#layout/button_confirm"
android:layout_gravity="center_horizontal"
android:text="#string/createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp"
android:layout_marginTop="15dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Does anyone have any tips on how can I keep the footer fixed, scroll down until the end of the list and then show the button? I want that it looks like the button is the last item at the List.
EDIT: Entire XML posted
The ListView and the Button should be in a RelativeLayout and in the Button you should set android:layout_below="#id/listview"
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#000000"
android:textColor="#000000" />
<Button
android:layout_below="#id/listview"
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:background="#layout/button_confirm"
android:text="#string/createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp" />
</RelativeLayout>
Try it in the following manner:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout //Header
android:layout_alignParentTop="true">
</RelativeLayout>
<ListView
android:layout_below="#+id/header" />
<RelativeLayout //Button(footer)
android:layout_alignParentBottom="true"
android:layout_below="#+id/listView" >
</RelativeLayout>
</RelativeLayout>
The only way I could achieve the exact requirements I explained above was doing the following:
-In the XML file with the layout of the list items, I added a button with android:visibility="gone".
-In my custom ListView adapter, I always add an empty object in the last position. I simply add an object with a flag that shows it is the last in the list.
-In the method getView() that I override in the custom Adapter, I check if the object in the current position has the flag indicating that it is the last in the list. If so, I set the button visibility to VISIBLE, otherwise I fill the other components.
If anyone is facing the same problem and needs some sample code from my solution just ask here.
Try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="baseTitle"
android:textColor="#FFFFFF"
android:textSize="18dp"
android:textStyle="bold" />
<Button
android:id="#+id/buttonHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/bottomButtomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<Button
android:id="#+id/myGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:gravity="center"
android:text="myGroups"
android:textColor="#000000"
android:textSize="13dp" />
<Button
android:id="#+id/createGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center"
android:text="createGroups"
android:textColor="#000000"
android:textSize="13dp" />
<Button
android:id="#+id/configurations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:gravity="center"
android:text="configurations"
android:textColor="#000000"
android:textSize="13dp" >
</Button>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/buttonBar"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/listContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/searchBarLayout"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/myGroupsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="myGroups"
android:textColor="#bdbdbd"
android:textSize="16dp"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp" >
</ImageView>
</RelativeLayout>
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="280dip"
android:layout_margin="7dip"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#000000"
android:textColor="#000000" />
<Button
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:text="createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

Two ListViews and One Button

I'm doing an android app and I want to separate layout in 3 parts like this:
but now the button is over the second listview but on the bottom of the screen, I don't know why.
I don't know if I have to use relativeLayout or linearLayout to including the listviews, and text are inside this or outside of relativelayout/linearLayout, and the last button what?
this is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="#+id/imageSelected"
android:text="#string/imgSelected"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginBottom="3dip"/>
<LinearLayout
android:id="#+id/linearLayoutImagenes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/imageSelected" >
<ListView
android:id="#+id/listaFusionPhotos"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout >
<TextView android:id="#+id/nameSelected"
android:text="#string/namSelected"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayoutImagenes"
android:layout_marginBottom="3dip"/>
<LinearLayout
android:id="#+id/linearLayoutNombres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/nameSelected"
>
<ListView
android:id="#+id/listaFusionNombres"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout >
<Button
android:id="#+id/fusion"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutNombres"
android:layout_marginTop="3dip"
android:text="Fusionar"
android:onClick="Mostrar_Registrados"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Try this. this looks like exactly same of the picture.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="11" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="1"/>
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
</ListView>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/listView2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
</ListView>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutNombres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/nameSelected"
android:layout_above="#+id/fusion" // "line added"
>
<Button
android:id="#+id/fusion"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutNombres" --> "remove this line"
android:layout_marginTop="3dip"
android:text="Fusionar"
android:onClick="Mostrar_Registrados"
android:layout_alignParentBottom="true"/>

Categories

Resources