I am getting error when I tried to put image view on top of surface view.
Here is my XML code please help me in this regard
<?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"
android:background="#android:color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EFE3AF"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1"
>
<SurfaceView
android:id="#+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"
android:scaleType="fitXY"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="right"
android:orientation="vertical"
android:paddingRight="#dimen/right01"
android:paddingTop="#dimen/top02" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/village" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
Above code works fine if I will add surface view up and image down, but I want other way around.
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="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EFE3AF"
android:orientation="vertical">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1">
<SurfaceView
android:id="#+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"
/>
<ImageView
android:layout_gravity="top|right"
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
Related
What I want is for qrcodetext to fit and display all the text in qrcode_layout and have qrimageView to fill the rest of qrcode_layout? But my layout below has the entire qrimageView cover qrcode_layout. I tried a bunch of other variations but without success.
Here is what it looks like.
Here is what I want it to look like.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="#+id/qrcodelayout">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/qrimageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/qrcodetext"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
Use following code. Align your textview to bottom and then align your Qrcode Image above text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/qrcodetext"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_marginTop="4dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/qrimageView"
android:layout_gravity="center_horizontal"
android:layout_above="#id/qrcodetext"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp" />
</RelativeLayout>
I think what i have understand you want is below: Plz check and tell me:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="#+id/qrcodelayout">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/qrcodetext"
android:gravity="center"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" />
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/qrimageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp" />
</LinearLayout>
</LinearLayout>
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>-->
</RelativeLayout>
I tried the following:
<?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" >
<FrameLayout
android:id="#+id/recipe_fragment_camera_preview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="#+id/recipe_fragment_imageview_pattern"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/imageview_description" />
</FrameLayout>
<Button
android:id="#+id/recipe_fragment_button_take_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_take_photo" />
Unfortunately this isnt working. The FrameLayout is hiding the button because the FrameLayout is taking the whole Screen. I want a button next to the FrameLayout. How can i achiev that?
try 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" >
<FrameLayout
android:id="#+id/recipe_fragment_camera_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/recipe_fragment_imageview_pattern"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/imageview_description" />
</FrameLayout>
<Button
android:id="#+id/recipe_fragment_button_take_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_take_photo" />
add in frameLayout and in Button:
android:layout_weight = "2"
just add Weight in FrameLayout
<FrameLayout android:layout_weight="1"
android:id="#+id/recipe_fragment_camera_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" >
Try 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">
<FrameLayout
android:id="#+id/recipe_fragment_camera_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#recipe_fragment_button_take_photo"
android:orientation="horizontal" >
<ImageView
android:id="#+id/recipe_fragment_imageview_pattern"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/imageview_description" />
</FrameLayout>
<Button
android:id="#+id/recipe_fragment_button_take_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="#string/button_take_photo" />
</RelativeLayout>
<?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"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="#drawable/stalker_background"
android:focusableInTouchMode="true" >
<ProgressBar
android:id="#+id/pb"
android:layout_height="75dp"
android:layout_width="75dp"
android:layout_gravity="center"
android:indeterminate="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="#+id/svProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="#+id/VPSlider"
android:layout_width="match_parent"
android:layout_height="175dp"
/>
<android.support.v4.app.FragmentTabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
Progress Bar appears at corner of the screen, how can I align it on centre of the screen. I have relative layout and I'm removing this progress bar after I have some thing to show on screen that's why I need this on top of other controls.
Try this..
Add android:layout_centerInParent="true" to your ProgressBar because you parent layout is RelativeLayout
<ProgressBar
android:id="#+id/pb"
android:layout_height="75dp"
android:layout_width="75dp"
android:layout_gravity="center"
android:indeterminate="true"
android:layout_centerInParent="true"
/>
Try this way,hope this will help you to solve your problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="#drawable/stalker_background"
android:focusableInTouchMode="true" >
<ProgressBar
android:id="#+id/pb"
android:layout_height="75dp"
android:layout_width="75dp"
android:layout_centerInParent="true"
android:indeterminate="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="#+id/svProfile"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
I have a question about layout android.
This is layout image that i want to make it. Like this:
This is image exmaple:
Here my 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/first_screen_bg"
tools:context=".LoginActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100" >
<LinearLayout
android:id="#id/linerTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="55"
android:background="#color/white"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:id="#id/linerBottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="45"
android:background="#color/grey" >
<LinearLayout
android:id="#id/linerMidle"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_gravity="top|center"
android:background="#color/black" >
</LinearLayout>
<RelativeLayout
android:id="#id/linerFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="-20dp"
android:background="#drawable/login_flag" >
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout><RelativeLayout>
</RelativeLayout>
But it not running.
Please help me. Thanks
change yout layout.xml to this:
<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/first_screen_bg"
tools:context=".LoginActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100" >
<LinearLayout
android:id="#id/linerTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="55"
android:background="#color/white"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:id="#id/linerBottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="45"
android:background="#color/grey" >
<LinearLayout
android:id="#id/linerMidle"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_gravity="top|center"
android:background="#color/black" >
</LinearLayout>
<RelativeLayout
android:id="#id/linerFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="-20dp"
android:background="#drawable/login_flag" >
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
I need result as this.
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">
<include layout="#layout/background_water"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include layout="#layout/finish_order_content"/>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/sendOrder"
android:text="Оформить заказ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:background="#drawable/btn_orange"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
If ScrollView have a very long content then Button not show (I see only ScrollView). How to fix it?
You can do something like below. Add android:layout_above="#id/sendOrder" to ScrollView to make it appear above the button and set its height fill_parent to fill the available space.
I'm not sure how <include layout="#layout/background_water"/> should work though as you haven't included it in the picture above.
<?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">
<Button
android:id="#+id/sendOrder"
android:text="Оформить заказ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:background="#drawable/btn_orange"/>
<include layout="#layout/background_water"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/sendOrder">
<include layout="#layout/finish_order_content"/>
</ScrollView>
</RelativeLayout>
// try this way
<?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">
<include layout="#layout/background_water"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/finish_order_content"/>
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/sendOrder"
android:text="Оформить заказ"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:background="#drawable/btn_orange"/>
</LinearLayout>
Try this:
<?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="fill_parent">
<include layout="#layout/background_water"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include layout="#layout/finish_order_content"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="0dp"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp" >
<Button
android:id="#+id/sendOrder"
android:text="Оформить заказ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:background="#drawable/btn_orange"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
The below should work. I took the liberty of removing unnecessary Views. Not sure what background_water actually is, but if it is supposed to be used as background, just remove your include (and the android:layout_below part I added to your ScrollView), and use android:background on the main RelativeLayout.
<?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">
<include layout="#layout/background_water"
android:id="#+id/include_layout"/>
<Button
android:id="#+id/sendOrder"
android:text="Оформить заказ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="8dp"
android:background="#drawable/btn_orange"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/sendOrder"
android:layout_below="#id/include_layout">
<include layout="#layout/finish_order_content"/>
</ScrollView>
</RelativeLayout>
Just try this once ,put below code in xml file and view its preview .
I hope this will help u or atleast provides u a clue :
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/button"
android:layout_marginBottom="10dip"
android:background="#bb9789" >
</ScrollView>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ff6790"
android:gravity="center"
android:text="Button" />
</RelativeLayout>
value of
activity_vertical_margin
is
16dip