There is the following simple layout:
<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" >
<com.google.android.maps.MapView
android:id="#+id/activityMainPoints"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:apiKey="0JsSnv022MOCCXMAJfsQTVtfCiH37VG5XykFLmQ"
android:clickable="true" />
</RelativeLayout>
As you can see, the MapView must fill the full parent container RelativeLayout, but it isn't! How can I fix it?
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Try this:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activityMainPoints"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0JsSnv022MOCCXMAJfsQTVtfCiH37VG5XykFLmQ"
android:clickable="true"
/>
Related
I'm using an image carousel and for more reason there's a margin between the carousel and the title bar or action bar http://imgur.com/a/Pvonn , and therefore I have to add a negative value to the top margin which is not desired...
activity_main.xml
<?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:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mock.vivofusion.MainActivity"
android:background="#f58b4c">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id ="#+id/viewPagerLayout">
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
.......
</RelativeLayout>
swipe_layout.xml(used for the carousel)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id = "#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I can also provide the java classes if needed (the code is 'copy pasted' from a website).
LE: How can I make the scroll to be accessible only on the carousel area? Everywhere I swipe the images keep moving.
This may be helpful, android:scaleType="fitStart".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id = "#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitStart" />
</LinearLayout>
I seem to be having an issue getting my app to scroll fully. I think there is an issue with the linear layout but would like your help to solve this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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="com.app.aks.fragments.ThreeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
//// some image and text views //////
</LinearLayout>
</LinearLayout>
</ScrollView>
The window only scrolls partially and not all the way to the bottom....Suggestions?
In your MainActivity.java
Or whereever you are using/initializing these views.
Try this for all the textviews/image views. which are nested inside.
view.setMovementMethod(new ScrollingMovementMethod());
The direct child of ScrollView should be another layout that supports multiple children, such as RelativeLayout or LinearLayout.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton ... />
<TextView ... />
<TextView ... />
<TextView ... />
</ScrollView>
Try with setting android:fillViewport="true" on the ScrollView:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
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" />
First of all, here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#android:color/white">
<LinearLayout [...]
android:layout_above"#+id/test">
</LinearLayout>
<LinearLayout [...]>
<LinearLayout [...]
android:id="#+id/test"/>
</LinearLayout>
</RelativeLayout>
This xml won't work...
Is there any option to do that? Setting the android:layout_above parameter to a view that's inside another one?
I modified a bit of your code .. please try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#android:color/white">
<LinearLayout [...]
android:id="#+id/test">
</LinearLayout>
<LinearLayout [...]
android:layout_below"#+id/test">
<LinearLayout [...]/>
</LinearLayout>
</RelativeLayout>
I am trying to include an existing layout in another layout file (xml). To position those layouts I need to give the included layout an id, so i am able to reference it, e.g.
I am using the following layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
...
</RelativeLayout>
I am including this layout in another layout, like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/container"
android:background="#drawable/bg"
>
<include android:id="#id/bar" layout="#layout/bar"/>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/bar"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
...
</LinearLayout>
</ScrollView>
</RelativeLayout>
This works fine and my ScrollView gets positioned below my bar and I am able to click on the bar, without the click events being intercepted by the ScrollView.
When I am trying to do the same in a different layout file it says that it canĀ“t find the resource #id/bar:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layoutContainer2"
>
<include android:id="#id/bar" layout="#layout/bar"/>
<ScrollView
android:id="#+id/scrollview2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#id/bar"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
...
</LinearLayout>
</ScrollView>
</RelativeLayout>
Anybody knows why that is?
change android:id="#id/bar" to android:id="#+id/someId"