Changing a FrameLayout to a CardView (following online tutorial) - android

I have tried to change my framelayout to a CardView using the following tutorial, https://guides.codepath.com/android/Using-the-CardView.
Originally I had the code,
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/note_tile_margin">
<LinearLayout
android:id="#+id/tile_clickable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#drawable/tile_selector"
android:clickable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/noteTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="#dimen/tile_padding"
android:layout_toLeftOf="#+id/btn_tile_expand"
android:ellipsize="end"
android:maxLines="#integer/max_tile_lines"
android:singleLine="false"
android:text="Write your message here... "
android:textColor="#color/tile_text" />
<LinearLayout
android:id="#+id/btn_tile_expand"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/click_selector"
android:gravity="top" >
<ImageView
android:id="#+id/btn_tile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:src="#drawable/icon_dark_expand" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/tile_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:visibility="gone" >
<ImageView
android:id="#+id/btn_tile_links"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Hyperlinks"
android:src="#drawable/icon_dark_web" />
<ImageView
android:id="#+id/btn_tile_delete"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="#string/deleteNote"
android:src="#drawable/icon_dark_delete" />
<ImageView
android:id="#+id/btn_tile_share"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="#string/share"
android:src="#drawable/icon_dark_share" />
<ImageView
android:id="#+id/btn_tile_copy"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Copy to clipboard"
android:src="#drawable/icon_dark_copy" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
then I followed the steps outlined in this tutorial and changed the bits it told me to. It seemed to be quite easy to follow the steps and the code is now,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content>
<LinearLayout
android:id="#+id/tile_clickable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#drawable/tile_selector"
android:clickable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/noteTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="#dimen/tile_padding"
android:layout_toLeftOf="#+id/btn_tile_expand"
android:ellipsize="end"
android:maxLines="#integer/max_tile_lines"
android:singleLine="false"
android:text="Write your message here... "
android:textColor="#color/tile_text" />
<LinearLayout
android:id="#+id/btn_tile_expand"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/click_selector"
android:gravity="top" >
<ImageView
android:id="#+id/btn_tile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:src="#drawable/icon_dark_expand" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/tile_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:visibility="gone" >
<ImageView
android:id="#+id/btn_tile_links"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Hyperlinks"
android:src="#drawable/icon_dark_web" />
<ImageView
android:id="#+id/btn_tile_delete"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="#string/deleteNote"
android:src="#drawable/icon_dark_delete" />
<ImageView
android:id="#+id/btn_tile_share"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="#string/share"
android:src="#drawable/icon_dark_share" />
<ImageView
android:id="#+id/btn_tile_copy"
style="#style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Copy to clipboard"
android:src="#drawable/icon_dark_copy" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
I then go to build the project and get the following error message:
How can I implement this CardView layout properly and what is going wrong?
Note: This is linked to my last problem, Rounding the corners of views in notepad android app.

You missed quotation mark in layout_height="wrap_content":
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Related

How to place imageView inside AutocompleteTextView

I am trying to align the ImageView inside the Autocomplete textView. I did this but the ImageView appears below the AutocomplteTextView. I changed the width of textView but same problem arises. I am looking for something like this:
Is there any way I can achieve this?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kalpu.placepick.SearchFragment">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<AutoCompleteTextView
android:id="#+id/acTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionHint="From"
android:dropDownHeight="match_parent"
android:hint="From"
android:visibility="visible"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#id/image"
android:padding="5dp"
android:layout_alignTop="#id/acTextView1"
android:layout_alignBottom="#id/acTextView1"
android:layout_alignRight="#id/acTextView1"
android:src="#mipmap/ic_arrow_drop_down"
/>
<AutoCompleteTextView
android:id="#+id/acTextView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/acTextView1"
android:completionHint="From"
android:dropDownHeight="match_parent"
android:hint="Intermediate (Optional) "
android:paddingTop="50dp"
android:visibility="visible" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#id/image"
android:padding="5dp"
android:layout_alignTop="#id/acTextView2"
android:layout_alignBottom="#id/acTextView2"
android:layout_alignRight="#id/acTextView1"
android:src="#mipmap/ic_arrow_drop_down"
/>
</LinearLayout>
</RelativeLayout>
Try below code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<AutoCompleteTextView
android:id="#+id/acTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionHint="From"
android:dropDownHeight="match_parent"
android:hint="From"
android:padding="20dp"
android:visibility="visible"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#id/image"
android:layout_alignParentRight="true"
android:src="#mipmap/your_image"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dp">
<AutoCompleteTextView
android:id="#+id/acTextView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionHint="From"
android:padding="20dp"
android:dropDownHeight="match_parent"
android:hint="Intermediate (Optional) "
android:visibility="visible" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#id/image"
android:src="#mipmap/your_image"
android:layout_alignParentRight="true"
/>
</RelativeLayout></LinearLayout>
Try this bro:
<FrameLayout
android:id="#+id/search"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<android.support.v7.widget.AppCompatAutoCompleteTextView
android:id="#+id/autoCompleteSearch"
android:layout_width="260dp"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:background="#android:color/transparent"
android:hint="Search by Event"
android:inputType="textAutoComplete"
android:textSize="14sp"
android:visibility="visible" />
<ImageView
android:id="#+id/searchBu"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical|right"
android:padding="10dp"
android:src="#mipmap/ic_arrow_drop_down" />
</FrameLayout>`
This is because you have placed the imageView below the AutoCompleteTextView in the xml. You will have to create a custom dropdown layout for images to appear in it.
You could check this library
https://github.com/koush/ion

How to put a TextView at the end of my ScrollView?

I want to add a TextView at the bottom of my ScrollView, in which I can put the version number. So when a user first enters the screen, they don't see the Version Number. After they Scroll down, they can see the version number at the bottom of the screen. I tried all kinds of ways, doesn't work.
The layout is pretty nested.
This is the screenshot of the layout implementing the code below
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linearLayoutThatDoesNotScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_splash"
android:clickable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/cnt_full">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerVertical="true"
android:layout_gravity="center">
<com.onkore.app.view.FontTextView
android:id="#+id/profile_num_trophies_won"
style="#style/Theme.App.Text.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/cnt_half"
android:drawablePadding="#dimen/cnt_tiny"
android:drawableStart="#drawable/icon_trophy"
android:fontFamily="thick"
android:gravity="center_vertical"
android:text="99"
android:textColor="#color/color_text_primary_inverse"
android:textSize="32sp" />
<com.onkore.app.view.FontTextView
style="#style/Theme.App.Text.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/profile_num_trophies_won"
android:text="#string/profile_trophies"
android:textColor="#color/color_text_primary_inverse" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/profile_user_pic"
android:layout_width="#dimen/profile_image_size"
android:layout_height="#dimen/profile_image_size"
android:layout_centerInParent="true"
android:layout_centerVertical="false"
android:src="#drawable/icon_profile_default"
app:riv_oval="true" />
<com.mikhaellopez.circularprogressbar.CircularProgressBar
android:id="#+id/profile_progress_bar"
android:layout_width="#dimen/profile_progress_bar_size"
android:layout_height="#dimen/profile_progress_bar_size"
android:layout_centerHorizontal="false"
android:layout_centerInParent="true"
android:layout_centerVertical="false"
app:cpb_background_progressbar_color="#color/color_base"
app:cpb_background_progressbar_width="#dimen/elev_06"
app:cpb_progress="25"
app:cpb_progressbar_color="#color/color_progress"
app:cpb_progressbar_width="#dimen/cnt_tiny" />
<com.onkore.app.view.FontTextView
android:id="#+id/profile_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/profile_progress_bar"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:layout_marginTop="#dimen/cnt_dbl"
android:textColor="#color/color_text_primary_inverse"
android:textSize="#dimen/text_size"
tools:text="Level 99" />
</RelativeLayout>
<com.onkore.app.view.FontTextView
android:id="#+id/profile_okoins"
style="#style/Theme.App.Coins.Balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
tools:text="999k" />
</RelativeLayout>
<com.onkore.app.view.FontTextView
style="#style/Theme.App.Tile.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/cnt_full"
android:layout_marginStart="#dimen/cnt_full"
android:layout_marginTop="#dimen/cnt_full"
android:background="#drawable/bg_card_empty"
android:gravity="center"
android:paddingBottom="#dimen/cnt_dbl"
android:paddingTop="#dimen/cnt_part"
android:text="Tap to Personalize"
android:textAllCaps="true"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_primary_translucent"
android:visibility="gone">
<com.onkore.app.view.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Friends" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
>
<TextView
android:id="#+id/versionName"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#color/cardview_dark_background"
android:gravity="center_vertical|center_horizontal|center"
android:text="HAHA"
android:textColor="#color/cardview_light_background"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
maybe something like this?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayoutThatDoesNotScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent"
android:clickable="true"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="1000dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="version"
android:textSize="50dp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>

How can I make xml file in android according to design in android?

and cannot solve problem problem with xml editing:
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/half_padding"
android:paddingLeft="#dimen/main_padding"
android:paddingRight="#dimen/main_padding"
android:paddingBottom="#dimen/main_padding"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="#dimen/half_padding"
android:gravity="center_vertical"
>
<TextView android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#color/news_category_color"
android:id="#+id/newsCategory"
android:singleLine="true"
android:ellipsize="end"
android:paddingLeft="#dimen/main_padding"
android:textSize="12dp"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/news_date_color"
android:id="#+id/newsDate"
android:textSize="12dp"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/news_category_color"
android:singleLine="true"
android:id="#+id/reklama"
android:text="#string/reklama"
android:paddingLeft="#dimen/main_padding"
android:textSize="12dp"
/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_offline"
android:id="#+id/offlineIcon"
android:layout_marginLeft="#dimen/main_padding"
/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<FrameLayout android:layout_width="99dp"
android:layout_height="74dp"
android:background="#drawable/gray_stroke"
android:padding="3dp"
>
<View android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/placeholder_small"
/>
<uz.muloqot.daryo.view.DaryoTextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#color/place_holder_bg"
android:textColor="#color/place_holder_text"
android:textSize="24dp"
android:text="#string/app_name"
/>
<uz.muloqot.daryo.view.DaryoWebImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:id="#+id/image"
/>
</FrameLayout>
<uz.muloqot.daryo.view.PTSansTextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/main_padding"
android:textSize="16dp"
android:textColor="#color/post_title_color"
android:id="#+id/newsTitle"
/>
</LinearLayout>
</LinearLayout>
while producing this code I get smth. like this:
however I should get this:
Add your code inside CardView And Add RecyclerView
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="4dp"
android:elevation="5dp">
Add Your Code HERE
</android.support.v7.widget.CardView>
You should use recyclerview layout ,Check the pic here

Unable create layout with image and text for listvieitem

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dip"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<TextView
android:id="#+id/rowcontact_txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="Usama Sadiq"
android:textColor="#3a3838"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/rowcontact_imgLocationIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_below="#+id/rowcontact_txtName"
android:layout_marginLeft="10dip" />
<TextView
android:id="#+id/rowcontact_txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rowcontact_txtName"
android:layout_toRightOf="#+id/rowcontact_imgLocationIcon"
android:text="Dubai"
android:textColor="#898788"
android:textSize="11.5dp" />
<ImageView
android:id="#+id/rowcontact_imgIcon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/rowcontact_txtLocation"
android:layout_marginLeft="94dp"
android:layout_toRightOf="#+id/rowcontact_txtName" />
</RelativeLayout>
</RelativeLayout>
i am trying to create layout for list-view item but i am not able to fix position of image and text with three different Position please tell me solution how to fix it. i have to create listviow item i am able to display list-view but like given screen
i have all icon an all but am unable to fix potion of text-view and image view like given screen
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="2"
android:layout_margin="5dp"
>
<TextView
android:id="#+id/rowcontact_txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Usama Sadiq"
android:textColor="#3a3838"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/rowcontact_txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rowcontact_txtName"
android:layout_toRightOf="#+id/rowcontact_imgLocationIcon"
android:text="Dubai"
android:textColor="#898788"
android:textSize="11.5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

How to show layout on the bottom of ListView

I have a layout xml like below:
<?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="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:maxWidth="71dip"
android:src="#drawable/logo_top" >
</ImageView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:adjustViewBounds="false"
android:clickable="true"
android:maxHeight="70dip"
android:src="#drawable/registeration_title" >
</ImageView>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" >
</TextView>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/linearframe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/informationFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/registeration_info1" />
<TextView
android:id="#+id/IDNumberTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="7dip"
android:layout_marginLeft="26dip"
android:text="TextView"
android:textColor="#drawable/textgreen" />
<TextView
android:id="#+id/EnableDateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="7dip"
android:layout_marginLeft="140dip"
android:text="TextView"
android:textColor="#drawable/textgreen" />
</FrameLayout>
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/linearframe"
android:text=" " />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView2"
android:layout_centerHorizontal="true"
android:src="#drawable/buy_in_60" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignLeft="#id/imageView5"
android:layout_alignRight="#id/imageView5"
android:layout_below="#id/imageView5" >
</ListView>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" " />
<FrameLayout
android:id="#+id/frameLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/listView1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="79dp" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/registeration_info2" />
<TextView
android:id="#+id/VersionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="48dip"
android:text="Version: 1.0"
android:textColor="#drawable/darkgreen" />
</FrameLayout>
<TextView
android:id="#+id/RevisionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/frameLayout2"
android:layout_centerHorizontal="true"
android:layout_marginLeft="79dp"
android:text="Revision: 16"
android:textColor="#drawable/darkgreen" />
</RelativeLayout>
some layouts below the ListView in the xml will disappear on the screen
and I tried to put the ListView and other layouts below the ListView into a scrollView
but the ListView will shrink, it looks too small, so i remove the ScrollView,
how should i do to let them appear on the screen without ScrollView?
You need to set Weight to your layouts like this way..
like you can set ListView Weight is= 0.80 and Bottom View is = 0.20 make sure parent Linear layout Weight sum is = 1.
You can see this is my xml file having List View (80% screen) and bottom Bar layout for Google Ads (almost 20% screen).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/layVrt"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_weight="0.72"
android:weightSum="1">
<ListView
android:layout_width="match_parent"
android:id="#+id/listViewGame"
android:textFilterEnabled="true"
android:layout_height="350dp"
android:layout_weight="0.73"></ListView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_weight="0.20"
android:layout_marginTop="5dp"
android:background="#drawable/rounded_corners_white"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:layout_height="50dp"
android:layout_marginBottom="3dp"
android:id="#+id/layoutAdMobList">
</LinearLayout>
</LinearLayout>
so this will be the output..
Or you can try something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_bar" >
</ListView>
<LinearLayout
android:id="#+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/bottom_bar"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ToggleButton
android:id="#+id/slider_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/bottom_toggle_button" />
<ToggleButton
android:id="#+id/list_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/bottom_left_button" />
<ToggleButton
android:id="#+id/map_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/bottom_right_button" />
</LinearLayout>
</RelativeLayout>
Place everything inside a RelativeLayout and use android:layout_above="#+id/bottom_bar" on the ListView

Categories

Resources