EditText appears in front of listview items - android

I have a RelativeLayout with ListView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:dividerHeight="-1sp"
android:paddingLeft="16dp"
android:paddingRight="16dp"/>
<include
android:id="#+id/commentFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/post_message" />
</RelativeLayout>
where the include called post_message is a RelativeLayout with an EditText and a Button.
The problem is the include appears above the list items at the bottom of the list. How can I make it appear below the list?

You have try this i checked it works for you.
& show like As shown in image
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:dividerHeight="-1sp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_above="#+id/commentFooter"
android:layout_alignParentTop="true"/>
<include
android:id="#+id/commentFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/article_view"
android:layout_alignParentBottom="true" />
</RelativeLayout>

Have you tried android:layout_below="" ?

Related

Cannot See BottomBar with ListView

I have this code:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeContainer"
xmlns:design="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:weightSum="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="#style/Theme.AppCompat"
tools:context="com.tag.instagramdemo.example.MainActivity"
android:background="#drawable/background1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:itemIconTint="#color/text"
android:enabled="false"
app:itemTextColor="#color/text"
android:animateLayoutChanges="true"
android:clickable="false"
design:menu = "#menu/menu_main"
android:contextClickable="false"/>
When I use this layout. I can't see the bottom bar and I can only see the listview. At the top there is the list and nothing else.
I tried to resolve your issue.
I hope it will work for you :)
Please have a look and tried
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
android:layout_above="#+id/bottomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:theme="#style/Theme.AppCompat"
android:weightSum="1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:animateLayoutChanges="true"
android:background="#ffffff"
android:clickable="false"
android:contextClickable="false"
android:enabled="false"
design:menu="#menu/navigation" />
</RelativeLayout>
If you have not added a parent layout, do add a parent layout. Enclose the listview inside swiperefreshlayout and enclose the bottombar & swiperefreshlayout inside a parent layout (for eg., relative layout)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:design="http://schemas.android.com/apk/res-auto"
....>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
...>
<ListView
android:id=... >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
android:enabled="false"
app:itemIconTint="#color/colorAccent"
app:itemTextColor="#color/colorPrimary"
android:animateLayoutChanges="true"
android:clickable="false"
android:contextClickable="false"
android:layout_below="#id/swipeContainer"
app:menu = "#menu/menu_main"/>
Also use
app:menu
instead of design:menu as suggested in
https://medium.com/#chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953
BottomNavigationView has a method inflateMenu(menu) and if you pass
your menu resource file inside it will work. Right after idea with the
wrong namespace appear in my mind so I tried to replace ‘design’ with
‘app’ namespace which automatically resolves the attributes. And it
actually works. The same story for other three attributes which exist
specifically for this view: itemBackground, itemIconTint,
itemTextColor.

Android ListView only scrolls when touching first or second list item

I use a ListView in a SwypeRefreshLayout and scrolling only works in the upper area of the View.
I also tried other layouts like LinearLayout, RelativeLayout and worked with a ScrollView, but it only scrolls on the first two elements of the list.
Whats wrong?
Fragment Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/DeviceOverviewRefresher"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="true"
android:divider="#android:color/transparent"
android:id="#+id/DeviceOverviewList" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
ListRowLayout:
<?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"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:id="#+id/Text"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp">
<TextView
android:text="Text"
android:textSize="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="60dp"
android:id="#+id/DeviceName" />
</LinearLayout>
<ImageView
android:id="#+id/Image"
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="1dp"
android:src="#drawable/logo"
android:layout_alignParentRight="false" />
</RelativeLayout>
Thx for your help!
Weird, but removing one line of code solved it.
I just removed the animation in my "ShowFragment" - Method.
var trans = fragmentManager.BeginTransaction();
// animation
//trans.SetCustomAnimations(Resource.Animation.slide_down, Resource.Animation.slide_up);

Android: Cannot add Button below Gridview

I want to add a button just below gridview. It just not sure, p.s. this framelayout is inside another framelayout (base container). I have tried to set heigh=0dp and weight=1, but no luck. please help :) thx
Here is my code,
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/baseContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_recent_swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_recent_gridview"
android:numColumns="auto_fit"
android:gravity="center"
android:stretchMode="columnWidth"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:listSelector="#00000000"
/>
</android.support.v4.widget.SwipeRefreshLayout>
<Button
android:id="#+id/recent_filterBtn"
android:layout_width="match_parent"
android:layout_height="34dp"
android:text="my button"
android:textColor="#drawable/button_text_color2"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
Put :
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_recent_swipeRefreshLayout"
android:weight = "1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
And remove the weight tag from the GridView

"layout_alignParentBottom" does not work in the Layout

I was adding a Bottom Bar below the ViewPager (on the bottom of the screen) by using include but it does not work. I have tried all the methods by adding LinearLayout/ RelativeLayout to wrap the include tag, even ViewPager; or adding code like layout_alignParentBottom=true, layout_gravity=bottom.
Is there any method to put it at the bottom, or any problem in my code?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:orientation="vertical" >
<include layout="#layout/Bottom_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
<android.support.v4.view.ViewPager
android:id="#+id/id_viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</android.support.v4.view.ViewPager>
</LinearLayout>
just try 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"
>
<include layout="#layout/Bottom_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"/>
<android.support.v4.view.ViewPager
android:id="#+id/id_viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="#+id/id_viewpager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</android.support.v4.view.ViewPager>
<include layout="#layout/Bottom_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
LinearLayout draws every child by the order it is declared, so if Bottom_bar is declared before id_viewpager, it will draw above ViewPager. If you switch the order, you'll get what you want.

How to make a webview is -10dp width and height of the parent layout?

How to make a webview is -10dp width and height of the parent layout with a background image look like the following image:
Updated:
The blue box is the screen.
The black box is the outer layout(#+id/wrapper) and the red box is the webview(#+id/webview)
The green box is some other layout.
I have tried with the following code but have no success.
If the content in the webview is too long, the outer layout will stretch. I want a fixed size webview inside the layout but I don't know how to achieve this.
Ps. The background image of the black box is not full screen.
Would somebody give me some hints?
<?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"
android:background="#drawable/common_background" >
... some other layout ...
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/wrapper_background" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
... some other layout ...
</RelativeLayout>
use
android:padding="10dip" to the parent of webview.
Use this code instead
it will look like As shown in image
xml Code:
<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"
android:background="#drawable/ic_launcher" >
... some other layout ...
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/ic_launcher" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
... some other layout ...
</RelativeLayout>
Not tested but you can try this:
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"
android:background="#drawable/wrapper_background" >
Try out 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"
android:background="#drawable/common_background" >
... some other layout ...
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:padding="10dip" <---- Apply this in your layout.
android:background="#drawable/wrapper_background" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
... some other layout ...
</RelativeLayout>
Use this code instead
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/someOtherLayout"
android:layout_centerInParent="true"
android:background="#drawable/wrapper_background" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
<Some Other Layout
android:id="#+id/someOtherLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />

Categories

Resources