RAW
RAW

Reputation: 7825

how to design great design's for a Android Activity

What I'm Trying to do

At the moment I'm creating a design for my Activity, which has different kind of "boxes" in it. Every of those "boxes", has diffrent informations in it. I created the design by hand on a piece of paper, but I won't get the idea down in my .xml!!

Question

On the bottom of this post you'll find a copyed "box" which I'd like to create for my app. Please help me to realize this, because I really don't get how to do this in my XML! I'm working with Android 4.0 (ICS).

Design of the box

Upvotes: 0

Views: 1532

Answers (2)

WarrenFaith
WarrenFaith

Reputation: 57702

I give you the pseudo layout:

<RelativeLayout>
    <TextView
        full width
        id:infobox/>
    <Button
        layoutParentRight
        below infobox/>
    <TextView
        layout_below infobox
        toLeftOf button/>
    // repeat the textView above and always below the previous one
</RelativeLayout>

With LinearLayouts:

<LinearLayout>
    <TextView infobox/>
    <LinearLayout>
        <LinearLayout>
            <TextView />
            <TextView />
            <TextView />
        </LinearLayout>
        <Button/>
    </LinearLayout>
</LinearLayout>

As you see it is much more complex and bloated. As I always get confused by horizontal/vertical orientation I leave this to you to find out :) Just experiment and if you can't get it to work, update your answer with the layout you tried.

Upvotes: 2

MRD
MRD

Reputation: 7184

Something like this should work:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/layout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" >

  <TextView
    android:id="@+id/box_title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Box Title" />

  <LinearLayout
    android:id="@+id/box_content"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/box_content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/box_content_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hans Max" />

        <TextView
            android:id="@+id/box_content_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Maxiburger 12" />

        <TextView
            android:id="@+id/box_content_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8002, Muster" />
      </LinearLayout>

      <ImageButton
        android:id="@+id/box_button"
        android:layout_weight="5"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
  </LinearLayout>

</LinearLayout>

Upvotes: 2

Related Questions