designing a layout with a picture in the center, and a textview on the left border

  • Replies:0
Zag Gol
  • Forum posts: 1

Jan 11, 2015, 12:13:32 AM via Website

I am trying to design a layout with 3 parts:

on the top (20 percent of the height) a TextView with the word "name". the text will change by run time.

(60 percent of the height) a picture that takes 80% from width. on the left border of the picture, a textview with the text "price" (the text will change by run time.) .half of the textview needs to fall on the left side of the picture, and the other half - needs to fall out of the picture (left to picture)

on the bottom (20 percent of the height) a TextView with the word "description". the text will change by run time.

this is my code:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android=... 

    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/dialog_text_product_name"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight= "1"
        android:gravity="center"
        android:textSize="25dp"
        android:visibility="visible"
        android:text="name"
        tools:ignore="ObsoleteLayoutParam" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight= "3"
        android:id="@+id/external_frame_layout">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <com.parse.ParseImageView
                android:id="@+id/img_row_logo"
                android:layout_below="@id/dialog_text_product_name"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/product_logo"
                android:visibility="visible">
            </com.parse.ParseImageView>
        </LinearLayout>

        <FrameLayout android:id="@+id/price_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true">
            <TextView
                android:id="@+id/price"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:textSize="35dp"
                android:text="price"
                >
            </TextView>
        </FrameLayout>
    </FrameLayout>
    <TextView
        android:id="@+id/dialog_text_product_desc"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight= "1"
        android:layout_below="@id/external_frame_layout"
        android:gravity="center"
        android:textSize="25dp"
        android:padding="30dp"
        android:visibility="visible"
        android:text="description"
        android:paddingTop="50dp"
        />
</TableLayout>

i have two problems:

putting the picture on 80 percent of the width. i can't use layout_weight to set it, becuase i am using the layout_weight to set the height.

putting the price textview on the left border.

Reply