Check Following Image.
![background activity content showing while opening keyboard or close. first layout goes up it take mili second to open keyboard.
Below Address field white part there is background activity content.]1
Manifest File
android:windowSoftInputMode="stateAlwaysHidden"
Here its my layout top Views. Help me to resolve this issue.
<?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"
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:clickable="true">
<include
android:id="#+id/top_bar"
layout="#layout/top_bar_steps_form" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/top_bar">
<FrameLayout
android:id="#+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:visibility="visible">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<LinearLayout
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom"
android:orientation="vertical"
android:visibility="visible">
</LinearLayout>
</RelativeLayout>
</ScrollView>
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
i was using Transparent theme Theme.AppCompat.Translucent
i just change theme and it fixed
Related
Is there a way to use some non scrollable view when the activity has ScrollView component?
I want that my button behaves similar to the button in the question below, I want it fixed on the bottom of the UI too:
how to set a button at a fixed location on the bottom of UI?
Here's my layout code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent ">
<FrameLayout
android:id="#+id/map_frameview"
android:layout_width="match_parent"
android:layout_height="200dp">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp">
</LinearLayout>
</LinearLayout>
</ScrollView>
Thanks in advance!
The link you have attached in your question shows how you can do it. You can use RelativeLayout for this. The idea is, you need to tell a button to stay on bottom of the screen & tell the scrollview to stay above the Button along with it's scrollable content like:
<?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">
<Button
android:id="#+id/btnMy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/btnMy">
<LinearLayout
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:layout_above="#id/btnMy"
android:orientation="vertical">
<FrameLayout
android:id="#+id/map_frameview"
android:layout_width="match_parent"
android:layout_height="200dp">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp">
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Here you can see that there is a background and above it there is a white layer on which contain are given. screenshot is of a website but i want to give that effect on my app. any help will be of great use.
You can do it like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context=".activity.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/yourBackgroudImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:bacground="#color/white"
android:layout_margin="20dp">
<!--your code inside white backgroud layout goes here-->
</LinearLayout>
</LinearLayout>
Just use a RelativeLayout which helps you to stack your views above each other,then provide a margin to the top layout
<?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="wrap_content">
<ImageView
android:src="#drawable/backgroundimage"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_margin="20dp"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Add Data here as required-->
</LinearLayout>
</RelativeLayout>
I have an activity layout with 2 FrameLayout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
tools:context="de.sioned.multivoc.AddWordActivity"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<include layout="#layout/toolbar_layout"/>
<ScrollView
android:id="#+id/scLeft"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/paneLeft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftTop"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftBottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/paneLeftTop"/>
</RelativeLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
The 2nd FrameLayout paneLeftBottom will at some point contain the following fragment:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/lyTop"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...some static fields...
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/lyTop">
<ListView
android:id="#+id/lvResult"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"/>
</RelativeLayout>
In this configuration the ListView is only shown with a height of one of it's rows instead several rows utilizing the available space. The ListView works fine but only one row at a time is displayed.
The same ListView fragment works fine when I put it into a 2-pane landscape layout. How can I make the ListView use the available space ?
Edit:
Found a partial solution by switching to a LinearLayout within the ScrollView. Only problem left is, that the bottom Framelayout overlays a bit of the top FrameLayout when I load the said fragment into it. But that is acceptable in this case as it is only temporary to select some data.
<ScrollView
android:id="#+id/scLeft"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:id="#+id/paneLeft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftBottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</ScrollView>
This right here
android:layout_width="match_parent"
android:layout_height="match_parent"
Should be
android:layout_width="match_parent"
android:layout_height="wrap_content"
I have a main Webview and a bottom sheet that shows up occasionally, overlaying it. The bottom one is also a Webview, shown green.
The problem is that if there is any selection in the main view, the selection handles and menu show through the bottom one and I want them to hide behind.
Here is the layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/my_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.gary.testandroid.TestActivity"
tools:showIn="#layout/activity_test">
<com.example.gary.testandroid.BrowseView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" />
<LinearLayout
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:clipToPadding="false">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lview1"
android:elevation="0dp"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight=".62"/>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bottom_view"
android:layout_alignParentBottom="true"
android:elevation="24dp"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight=".38"/>
</LinearLayout>
</RelativeLayout>
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" />