i am stuck from two days with relative layout..here is my screen snap in linear layout
so its fine. but now i want to add refresh button somewhere on map but i found that it is not possible with linear layout. so i tried in relative layout but cant even get screen as above.
my footer layout is always shown at top.. here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- include title bar for all screen -->
<include
android:id="#+id/include1"
layout="#layout/titlebar_layout" />
<com.google.android.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.63"
android:apiKey="0VkXbAOFvAq7b6uaGHSmnS2a2VosPxoS6ceHY_g"
android:clickable="true" >
</com.google.android.maps.MapView>
<include
android:id="#+id/include2"
android:layout_marginBottom="38dp"
layout="#layout/bottom_layout"/>
</LinearLayout>
any help will be greatly appreciated. thanks in advance
Try this. Use a frame layout and put the mapview and button inside the frame layout. Thus button will be placed above the mapview. Place it according to your need.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- include title bar for all screen -->
<include
android:id="#+id/include1"
layout="#layout/titlebar_layout" />
<FrameLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_width="1.0" >
<com.google.android.maps.MapView
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.63"
android:apiKey="0VkXbAOFvAq7b6uaGHSmnS2a2VosPxoS6ceHY_g"
android:clickable="true" >
</com.google.android.maps.MapView>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right" />
</FrameLayout>
<include
android:id="#+id/include2"
android:layout_marginBottom="38dp"
layout="#layout/bottom_layout"/>
</LinearLayout>
Hope this helps...!!!
RelativeLayout is probably what you want. It can be difficult to program, as you need to define the bottom View first, and then the Views which come above it on the screen.
Check out these tutorials for some more assistance on using RelativeLayouts. The best way to learn is by doing it! Experiment with various layouts until you figure out how the rules work. Then it should be pretty simple to recreate this as a RelativeLayout.
Related
I want to achieve the UI in the below photo. I am not able to decide which layout should I use. Kindly anyone give some points to this:
Use a Linear layout with vertical orientation and within the linear layout(vertical), include linear layouts with horizontal orientation
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!--
online icon
call icon
-->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--
Gratuity icon
-->
</LinearLayout>
Need help,
See the following screen, (This is my actual home screen)
But, when I run my Application It looks as follows (Screen When I run my application
Here I need to drag (Scroll) the screen to see the footer part. I wants to avoid this, Can anybody help me out in this Please. Thank You.!
hope this will help you. Use following
<?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:orientation="vertical">
<!-- header part -->
<LinearLayout
android:id="#+id/ll_header"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="match_parent">
...
</LinearLayout>
<!-- scroll view part -->
<ScrollView
android:id="#+id/sv_container"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_above="#+id/ll_fooetr">
</ScrollView>
<!-- footer part -->
<LinearLayout
android:id="#+id/ll_footer"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent">
...
</LinearLayout>
</RelativeLayout>
My suggestion is to use LinearLayout or RelativeLayout for your activity, and inside it use a ScrollView for the inside part (which should be scrolled).
So, perhaps something like 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:orientation="vertical">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent">
<!-- all your scrollable stuff goes here -->
</ScrollView>
<!-- here's your footer -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
...
</LinearLayout>
</LinearLayout>
Documentation on ScrollView
Edit:
I think RelativeLayout (as main Layout) will serve you the best, as it allows you to align itself against parent's edges.
Documentation on RelativeLayout
I have designed my layout and on smaller phone screens not everything is visible, so I'd like to make it scrollable, could somebody help me with how to go about this? Below is the basic structure of my layout.
<?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:id="#+id/allowanceroot"
android:background="#drawable/background"
>
--TextView--
--EditText--
--TextView--
--EditText--
--TextView--
--EditText--
</LinearLayout>
Do I just contain my TextViews and EditTexts in a LinearLayout, and then contain that in a ScrollView? Also is there anything I need to do programmatically?
Try wrapping it in a scrollview
https://stackoverflow.com/a/4202608/661079
There is nothing else you need to do
Try like this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView />
<TextView />
</LinearLayout>
</ScrollView>
I want to place 3 linear layouts on same page of android.
Two besides each other and the other one below the two.
The view is in landscape mode and it should cover the whole screen.
How to do that in xml file?
I am not being able to post my code. Seems like its not working
You will do something like this
<LL orientation=vertical android:layout_height="fill_parent">
<LL orientation:horizontal>
<LL><!-- First of the two who are beside--></LL>
<LL><!-- Second of the two who are beside--></LL>
</LL>
<LL>
</LL>
</LL>
You can use RelativeLayout for that:
<?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">
<LinearLayout
android:id="#+id/layoutLeftTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
<!-- Content of the first layout -->
</LinearLayout>
<LinearLayout
android:id="#+id/layoutRightTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true">
<!-- Content of the second layout -->
</LinearLayout>
<LinearLayout
android:id="#+id/layoutBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<!-- Content of the third layout at bottom -->
</LinearLayout>
</RelativeLayout>
I have a scrollview with a linear layout inside. One of the elements inside this linearlayout is a glsurfaceview.
This all works correctly and when I scroll the glsurfaceview moves up and down however when the glsurfaceview reaches the top or bottom of where it should of the scrollview where it should be clipped it is not and is continued outside of the scrollview. This screenshot should make it clearer:
Don't think it's completly nessecary but here is my layout.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="wrap_content"
android:orientation="vertical"
android:padding="6dip"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
>
<!-- LOTS OF SEEKBARS/TEXTVIEWS -->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.4"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:orientation="horizontal" >
<android.opengl.GLSurfaceView android:id="#+id/glview"
android:layout_width="100px"
android:layout_height="250px"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<!-- OK/CANCEL BUTTONS -->
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
All help much appreciated :)
Hosting SurfaceViews inside ScrollView (or Listview, etc.) is currently not supported.
You may use below lines for removing over scrolling :
glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
glView.setZOrderOnTop(true);
glView.setZOrderMediaOverlay(true);
And for removing black background :
linearLayout.setBackgroundColor(context.getResources().getColor(R.color.white));
linearLayout.addView(glView);
Also add below line in your manifests file :
android:hardwareAccelerated="true"
It is not about support as answered abowe. The cause of issue is that GLSurfaceView is not on the view level. In short: for you case you have GLSurfaceView at the first level, then other views with holes in views abowe GLSurfaceView (this handles by windows manager, and it dosent matter where you put GLSurfaceView on xml, it will be on first level in any case and others views on next level)
So, what you need is to force view update, and there is work around: you should put scroll with GLSurfaceView or (RecyclerView with GLSurfaceViews) "between" two FrameLayouts. something like this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
---- here should be linear layout with your glView, or RecyclerView instead if required ----
</ScrollView>
--- this frame also required: ---
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent" />
</FrameLayout>