How to set a linear layout of buttons at the top of an image (layouts in android)?

Opal

I would like the radio button options to show up at the top, and the picture right below. How should I go about this? I have been playing around with putting my custom view in a linear layout and then setting android:orientation = horizontal but I don't think that works like I think it does.

enter image description here


My activity_main.xml file:

<?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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RadioGroup
        android:id="@+id/greyorcolor"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/grey"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Greyscale" />

        <RadioButton
            android:id="@+id/color"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Color" />
    </RadioGroup>

    <RadioGroup
        android:id="@+id/smallorlarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/large"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Large" />

        <RadioButton
            android:id="@+id/small"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Small" />
    </RadioGroup>
</LinearLayout>


    <edu.berkeley.cs160.opalkale.prog2.DrawingView
        android:id="@+id/drawing"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_marginBottom="3dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="3dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:src="@drawable/crayon" />


</LinearLayout>
Hamid Shatu

Here is your corrected XML portion.

<edu.berkeley.cs160.opalkale.prog2.DrawingView
    android:id="@+id/drawing"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_marginBottom="3dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="3dp"
    android:layout_weight="1"
    android:orientation="vertical"
    android:src="@drawable/ic_launcher" />

You are putting "0dip" in android:layout_width instead of android:layout_height thats why you are getting the result. Replace this corrected XML portion, you will get your Layout right.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to set background image in Linear layout dynamically using Parser in android

From Dev

How to set image for imageview and linear layout from Drawable path in android

From Dev

how to set border linear layout on top and bottom

From Dev

How to arrange two linear layouts inside a relative layout in android?

From Dev

how to set one linear layout below another linear layout in android

From Dev

how to set one linear layout below another linear layout in android

From Dev

android how to set buttons in layout for all resolution

From Dev

Android: How to set up Grid Layout inside Linear layout?

From Dev

Align Image View to top of the screen in a linear layout

From Dev

How to set chosen image from gallery to linear layout using intent?

From Dev

how to change order of statically created layouts in a linear layout dynamically? (Android Studio)

From Dev

Android Linear layout image with text

From Dev

Set Linear layout View in Android

From Dev

How to combine canvas drawing with android activity layout which includes buttons and layouts?

From Dev

How to give Space between Linear Layouts in android

From Dev

How to set content in a Linear layout to the BOTTOM of the Screen in Android.?

From Dev

How to align buttons below textview in linear layout

From Dev

image buttons or layouts onclick?

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

Understanding Android Linear Layouts

From Dev

How to add image to top layout

From Dev

How to merge Linear Layout and Table Layout at android?

From Dev

how to set inflate layout center which added dynamically in linear layout Android

From Dev

How to set layout constraints with top layout guide?

From Dev

How to fit all the linear layouts one after the other in a relative layout so that it adjusts its height if more linear layouts are added

From Dev

Creating an android layout of image buttons that is scrollable?

From Dev

How to center fit image in linear layout?

From Dev

How to set the border color for linear layout

Related Related

  1. 1

    how to set background image in Linear layout dynamically using Parser in android

  2. 2

    How to set image for imageview and linear layout from Drawable path in android

  3. 3

    how to set border linear layout on top and bottom

  4. 4

    How to arrange two linear layouts inside a relative layout in android?

  5. 5

    how to set one linear layout below another linear layout in android

  6. 6

    how to set one linear layout below another linear layout in android

  7. 7

    android how to set buttons in layout for all resolution

  8. 8

    Android: How to set up Grid Layout inside Linear layout?

  9. 9

    Align Image View to top of the screen in a linear layout

  10. 10

    How to set chosen image from gallery to linear layout using intent?

  11. 11

    how to change order of statically created layouts in a linear layout dynamically? (Android Studio)

  12. 12

    Android Linear layout image with text

  13. 13

    Set Linear layout View in Android

  14. 14

    How to combine canvas drawing with android activity layout which includes buttons and layouts?

  15. 15

    How to give Space between Linear Layouts in android

  16. 16

    How to set content in a Linear layout to the BOTTOM of the Screen in Android.?

  17. 17

    How to align buttons below textview in linear layout

  18. 18

    image buttons or layouts onclick?

  19. 19

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  20. 20

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  21. 21

    Understanding Android Linear Layouts

  22. 22

    How to add image to top layout

  23. 23

    How to merge Linear Layout and Table Layout at android?

  24. 24

    how to set inflate layout center which added dynamically in linear layout Android

  25. 25

    How to set layout constraints with top layout guide?

  26. 26

    How to fit all the linear layouts one after the other in a relative layout so that it adjusts its height if more linear layouts are added

  27. 27

    Creating an android layout of image buttons that is scrollable?

  28. 28

    How to center fit image in linear layout?

  29. 29

    How to set the border color for linear layout

HotTag

Archive