Android ImageView is not displayed - android

I ran into an issue concerning two ImageViews which are displayed on the layout.xml but not when running the app.
<?xml version="1.0" encoding="utf-8"?>
<!-- Outter Linear Layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linearOutter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#e6e6e9" >
<!-- First inner Linear Layout -->
<LinearLayout
android:id="#+id/linearInner1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.18"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/moyland_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/moyland" />
<ImageView
android:id="#+id/hsrw_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/hsrw" />
</LinearLayout>
<!-- Title -->
<org.hsrw.artandcycle.util.AutoResizeTextView
android:id="#+id/widget37"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:fontFamily="sans-serif-thin"
android:gravity="center"
android:text="#string/app_name_upper"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0C1273"
android:maxLines="1"
android:textSize="100sp" />
<!-- Second inner Linear Layout -->
<LinearLayout
android:id="#+id/linearInner2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.18"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/gelderland_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/erfgoed_gelderland" />
<ImageView
android:id="#+id/interreg_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/interreg" />
</LinearLayout>
<!-- Third inner Linear Layout -->
<LinearLayout
android:id="#+id/linearInner3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.18"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<ImageView
android:id="#+id/erw_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/erw" />
<ImageView
android:id="#+id/gelderland2_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:src="#drawable/province_gelderland" />
</LinearLayout>
<ImageView
android:id="#+id/foerder_logo"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.18"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center"
android:src="#drawable/foerder" />
<ImageView
android:id="#+id/wfg_logo"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.18"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center"
android:src="#drawable/wfg" />
</LinearLayout>
This is my layout. Everything is displayed as it is supposed to be but the last two image views are not displayed on my Galaxy Nexus.
What did I do wrong?

The problem was the dimension of the last two images.
I reduced the width of those images to 800. Before the width was about 1300 pixels.

Related

Android, Layout: How do I get my button to overlay existing layout in axml?

As for most of you: we design our screens for our app in photoshop and then try to transfer them into Visual Studio.
This is a screenshot of our app FROM PHOTOSHOP:
You could imagine, the further we go the harder it gets. The center screen was easy but the left and right one - oh boy...
Anyway, today I'm here for the right one.
As you can see, there are these headlines such as: "Show Us Love For Asia".
This whole box shows a photo, a headline, a few extra infos AND:
a profile picture.
The whole is a scrollview and the white bars underneath each box are actually pngs. The reason is, that we need them to be equally sized on each different platform. Anyway - the profile picture is overlapping the picture box and the white divider png in between the picture boxes.
And here is the question: how the hell would we implement that into our axml?
As far as the screen is, this is it in xml:
<?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:id="#+id/layoutadventure"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="17"
android:layout_height="0dp"
android:background="#23313e"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:src="#drawable/sub_category_europe"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="30"
android:id="#+id/imgSubchallenge" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="40"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center|bottom"
android:id="#+id/txtSub"
android:layout_weight="60"
android:gravity="center|bottom"
android:text="Positive Thinking"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold|italic" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="5"
android:layout_gravity="top|center"
android:gravity="top|center"
android:src="#drawable/dotted_line_challenges" />
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="35"
android:layout_height="0dp"
android:orientation="vertical" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:src="#drawable/bar2"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="5" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="25"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:orientation="vertical" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Total"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Done"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Exp"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="25"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:orientation="vertical" />
<TextView
android:id="#+id/totalChallenges"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Total"
android:gravity="right"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<TextView
android:id="#+id/totalChallengesDone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Done"
android:gravity="right"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<TextView
android:id="#+id/totalXP"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="Exp"
android:gravity="right"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="25"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:orientation="vertical" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="82.5"
android:scrollbars="none"
android:id="#+id/scrlview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/linlayout"
android:orientation="vertical" />
</ScrollView>
</LinearLayout>
So you probably see the dilemma: the profile picture is halfway in one column of the scrollview and halfway in another column.
Can you provide any help for that? THANKS SO MUCH :)
Try this i hope this will help you. This is for only "Show Us Love For Asia" one item only.
<?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">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="500dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="vertical"
android:background="#color/colorAccent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".8"
android:background="#color/colorPrimary">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".2"
android:background="#color/colorAccent">
</LinearLayout>
</LinearLayout>
<android.support.v4.widget.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher_round"
android:layout_gravity="bottom"
android:layout_marginBottom="75dp"/>
</FrameLayout>
</LinearLayout>

Buttons aren't shown in the LinearLayout

I want that it looks so (this is a screenshot from the Graphical Layout editor):
So I created the layout:
<?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" >
<LinearLayout
android:id="#+id/controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/clearButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/clearButtonText"
android:layout_weight="1"
/>
<EditText
android:id="#+id/searchText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="5"
android:hint="#string/defaultSearchText"
>
<requestFocus/>
</EditText>
<Button
android:id="#+id/addButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/addButtonText"
android:layout_weight="1"
/>
</LinearLayout>
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
But when I ran my app on the emulator I saw:
When I clicked on the loupe there was still no sign of the buttons.
I think you should use weights for the width of the elements of your horizontal layout. This also means the width of the elements with a weight should be 0dp
<LinearLayout
android:id="#+id/controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/clearButton"
android:layout_width="0dp"
android:layout_weight="0.2"
android:layout_height="match_parent"
android:text="#string/clearButtonText"
/>
<EditText
android:id="#+id/searchText"
android:layout_width="0dp"
android:layout_weight="0.6"
android:layout_height="match_parent"
android:hint="#string/defaultSearchText"
>
<requestFocus/>
</EditText>
<Button
android:id="#+id/addButton"
android:layout_width="0dp"
android:layout_weight="0.3"
android:layout_height="match_parent"
android:text="#string/addButtonText"
/>
</LinearLayout>

Restricting fragment size depending on fixed footer

I am creating an android app with the above design in mind. I have made a custom action bar and stuck that to the onCreateOptionsMenu in my MainActivity.
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.action_bar);
I have also created a fixed footer in my MainActivity which is basically the imageviews for triggering different fragments in the app. Now these imageviews are set to wrap_content for their heights.
My questions are -
How do I restrict the size of my fragments so it sticks to the fixed viewgroup at the bottom as it does not have a specific height?
Is this the best approach to implementing such a design where there is a fixed footer to swap between fragments?
How to create and add a re-usable UI component similar to something like a google card where I can push in data from the server and include those dynamically in the scrollview.
Thank you.
Edit 1
activity_main -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/mainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="dd.MainActivity" >
<!-- Footer aligned to bottom -->
<LinearLayout
android:id="#+id/llFooterPlaceholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#color/green" />
<LinearLayout
android:id="#+id/llFooterMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bottom_bar"
android:orientation="horizontal" >
<ImageView
android:id="#+id/iv1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:scaleType="fitCenter"
android:src="#drawable/state_definition_iv1" />
<ImageView
android:id="#+id/iv2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:scaleType="fitCenter"
android:src="#drawable/state_definition_iv2" />
<ImageView
android:id="#+id/iv3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="#color/green"
android:scaleType="center"
android:src="#drawable/state_definition_iv3" />
<ImageView
android:id="#+id/iv4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:scaleType="fitCenter"
android:src="#drawable/state_definition_iv4" />
<ImageView
android:id="#+id/iv5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:scaleType="fitCenter"
android:src="#drawable/state_definition_iv5" />
</LinearLayout>
</LinearLayout>
<!-- Scrollable item above footer -->
<ScrollView
android:id="#+id/svContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/llFooterPlaceholder"
android:layout_alignParentTop="true" >
<!-- Inflate the contents of the ScrollView dynamicaly -->
</ScrollView>
</RelativeLayout>
fragment1 which is activated onClick of iv1 of the footer (layout not complete yet) -
<?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="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:background="#444"
android:orientation="horizontal"
android:padding="#dimen/item_padding" >
<ImageView
android:id="#+id/ivAvtar"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:background="#000"
android:scaleType="fitCenter" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:background="#fff"
android:orientation="vertical" >
<TextView
android:id="#+id/tvUsername"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:background="#0ff"
android:text="Username"
android:textColor="#color/green"
android:textStyle="bold" />
<TextView
android:id="#+id/tvImageTitle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:background="#ff0"
android:text="Title"
android:textColor="#color/orange"
android:textStyle="italic" />
</LinearLayout>
<TextView
android:id="#+id/tvTimestamp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center"
android:text="Timestamp"
android:textColor="#color/green"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/ivImage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="60"
android:background="#999"
android:padding="#dimen/item_padding"
android:scaleType="fitCenter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:background="#EEE"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="80"
android:background="#000"
android:orientation="horizontal" >
</LinearLayout>
<ImageView
android:id="#+id/ivShare"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:background="#ddd"
android:padding="#dimen/item_padding"
android:scaleType="fitCenter" />
</LinearLayout>
</LinearLayout>
Change your ScrollView height from fill_parent to wrap_content. Because android:layout_height="fill_parent" your ScrollView come over your llFooterPlaceholder
like this
<ScrollView
android:id="#+id/svContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/llFooterPlaceholder"
android:layout_alignParentTop="true" >
<!-- Inflate the contents of the ScrollView dynamicaly -->
</ScrollView>

Android: How can I retrieve ListView height and set ListView Items (cells) height depending on ListView Height?

I have some class LoginActivity.java. In the onCreate method I retrieve ListView:
ListView list = (ListView)findViewById(R.id.snListView);
then:
list.setAdapter(adapter);
In addition there are login.xml layout - there are:
<ListView
android:id="#+id/snListView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
and sn_row.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#drawable/listview_item_background"
android:orientation="horizontal" >
...
At the moment I have cell's height 100dp, I need that cell's height will depend on device, I mean I have here 5 cells showing at login screen in ListView and I need that these 5 rows will fit the ListView (cell's height = ListView's height/5).
that cells should cover the entire screen?
In that case use a LinearLayout instead and add the Relative as child views, for example:
<?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"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon48x48_2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon48x48_2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon48x48_2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon48x48_2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon48x48_2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test" />
</LinearLayout>
</LinearLayout>
Hope this helps!

Android + Which layout would you suggest?

I'm laying out a row for use in a ListView and I need a little help. The row will look like this:
Below is what I have so far, the highlight bg is not showing up and the text won't align center (sticks to the top).
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_margin="0dp"
android:background="#color/grey">
<!-- shine -->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/imgShine"
android:background="#color/shine"
android:layout_height="0dp"
android:layout_width="fill_parent"
android:layout_weight="1" />
<View
android:layout_height="0dp"
android:layout_width="fill_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:id="#+id/ll"
android:layout_gravity="center_vertical">
<!-- cal graphic -->
<RelativeLayout
android:id="#+id/rl1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp">
<!-- cal bg -->
<ImageView
android:id="#+id/imageView1"
android:src="#drawable/cal"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" />
<!-- month -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvMonth"
android:textSize="11sp"
android:layout_marginLeft="11dp"
android:layout_marginTop="10dp"
android:textColor="#drawable/list_cal_selector" />
<!-- day -->
<TextView
android:id="#+id/tvDay"
android:textSize="23sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvMonth"
android:layout_marginTop="2dp"
android:layout_centerHorizontal="true"
android:textColor="#drawable/list_cal_selector" />
</RelativeLayout>
<!-- text and button graphic -->
<RelativeLayout
android:id="#+id/rl2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_gravity="center_vertical">
<!-- team name -->
<TextView
android:id="#+id/tvTeam"
android:textSize="23dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:textColor="#drawable/list_text_selector" />
<TextView
android:id="#+id/tvTime"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvTeam"
android:textColor="#drawable/list_text_selector" />
<TextView
android:id="#+id/tvStation"
android:textSize="12sp"
android:paddingLeft="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvTeam"
android:layout_toRightOf="#+id/tvTime"
android:textColor="#drawable/list_text_selector" />
<!-- add button -->
<ImageView
android:id="#+id/imgAddBtn"
android:src="#drawable/btn"
android:layout_height="wrap_content"
android:layout_width="60dp"
android:scaleType="fitCenter"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:padding="10dp" />
<!-- divider -->
<ImageView
android:id="#+id/imgDivider"
android:src="#drawable/divider"
android:layout_height="fill_parent"
android:layout_width="2dp"
android:layout_toLeftOf="#id/imgAddBtn"
android:cropToPadding="false" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
I would use just one RelativeLayout. It will avoid the use of various Layouts and
its easier to place componentes on screen.
edit: This solution works, but I don't know if it's the best:
<?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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_weight="0.25"/>
<ImageView
android:layout_weight="0.5"
android:layout_height="0dp"
android:layout_width="50dp"
android:background="#dedede"/>
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_weight="0.25"/>
</LinearLayout>
<!--
...
-->
</RelativeLayout>
Look at this tutorials you can choose which layout is best. Every layout has own merits and demerits. Only one that layout is not best in android but in most cases Relative layout easy to use because it has move to easy any where of UI.
just like your matches problems, tutorials
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
you can see more layout of in developer.android.con. which has to learn more simply way. here some Best links you can see various layouts.
http://developer.android.com/resources/tutorials/views/hello-relativelayout.html
http://developer.android.com/guide/topics/ui/layout-objects.html
http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-relative-layouts/
http://www.learn-android.com/2010/01/05/android-layout-tutorial/
Check this out
![<?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="35dp"
android:orientation="horizontal" >
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:scaleType="centerInside"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Row 1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Row 2" />
<TextView
android:layout_marginLeft="10dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Row 3" />
</LinearLayout>
</LinearLayout>
<View android:layout_height="match_parent"
android:layout_width="2dp"
android:background="#fff"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:scaleType="centerInside"
android:src="#drawable/ic_launcher" />
</LinearLayout>

Categories

Resources