Whenever I create an ImageView in my XML the emulator crashes.
<?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"
android:padding="10px"
android:background="#drawable/words_background">
<EditText
android:id="#+id/letters"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:hint="#string/enter_letters" />
<TextView
android:id="#+id/moreText"
android:text="#string/more"
android:layout_alignLeft="#id/letters"
android:layout_below="#id/letters"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:typeface="normal"
android:paddingLeft="5dp"
android:textStyle="bold" />
<Spinner
android:id="#+id/maxSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="#id/letters"
android:layout_alignRight="#id/letters"
android:visibility="gone" />
<Spinner
android:id="#+id/minSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="#id/maxSpinner"
android:layout_alignRight="#id/letters"
android:visibility="gone" />
<TextView
android:id="#+id/lettersQuestion"
android:typeface="sans"
android:text="#string/question"
android:gravity="right"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true">
</TextView>
<ImageView
android:id="#+id/logo_image" />
</RelativeLayout>
You are missing the + in a few of your id references, and layout_alignRight will accept "true" or "false" only (you are probably looking for layout_ToRightOf)toTherightOf! AND an ImageView needs height and width set to something.
You should definitely look at your LogCat for the exact error,
but your XML should look like this
<RelativeLayout id="#+id/rel_layout">
<Spinner
android:id="#+id/maxSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/letters"
android:visibility="gone"/>
<Spinner
android:id="#+id/minSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="#+id/maxSpinner"
android:layout_toRightOf="#+id/letters"
android:visibility="gone"/>
<TextView
android:id="#+id/lettersQuestion"
android:typeface="sans"
android:text="#string/question"
android:gravity="right"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"/>
<ImageView
android:id="#+id/logo_image"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</RelativeLayout>
Related
I am using three line on center of the screen ; first two line is visible but last line(Textview andhave) is not visible
i have share full xml file please see
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backgroundcolor"
>
<RelativeLayout
android:id="#+id/rel_jobDesc"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text=" Daily listing "
android:textColor="#color/textcolor"
android:textSize="20sp" />
<ImageView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#drawable/li" />
</RelativeLayout>
<TextView
android:layout_below="#+id/rel_jobDesc"
android:id="#+id/txtprev"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="#color/listhead"
android:textColor="#color/textcolor"
/>
<ListView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtprev"
android:cacheColorHint="#00000000"
android:scrollingCache="false"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:smoothScrollbar="true" >
</ListView>
<TextView
android:id="#+id/belowtext"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="#color/listhead"
android:layout_below="#+id/list"
android:textColor="#color/textcolor"
/>
<Button
android:id="#+id/btnprev"
android:background="#drawable/prev"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_below="#+id/belowtext"
android:layout_marginLeft="20dp"
/>
<Button
android:background="#drawable/next"
android:layout_width="90dp"
android:layout_height="40dp"
android:id="#+id/btnnext"
android:layout_below="#+id/belowtext"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/btnprev"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:id="#+id/txttxt">
<TextView
android:id="#+id/arethese"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Are these the property you are looking for? "
android:textColor="#color/textcolor"
/>
<RelativeLayout
android:id="#+id/loginlayout"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_below="#+id/arethese">
<TextView
android:id="#+id/ifnot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="If not, "
android:textColor="#color/textcolor"
/>
<TextView
android:layout_toRightOf="#+id/ifnot"
android:id="#+id/txtlogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="login "
android:textColor="#color/textcolor"
/>
<TextView
android:layout_toRightOf="#+id/txtlogin"
android:id="#+id/orcontinue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="or continue your "
android:textColor="#color/textcolor"
/>
<TextView
android:layout_toRightOf="#+id/orcontinue"
android:id="#+id/txtsearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="search "
android:textColor="#color/textcolor"
/>
</RelativeLayout>
</RelativeLayout>
<TextView
android:layout_below="#+id/txttxt"
android:id="#+id/andhave"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:text="#string/andhave"
android:textColor="#color/textcolor"
/>
<Button
android:id="#+id/login"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:background="#drawable/greenrounded"
android:text="Register" />
<Button
android:id="#+id/search"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#drawable/greenrounded"
android:text="Search" />
</RelativeLayout>
Last Textview andhave and have is not showing
Please suggest me , what i am doing worng.
Please try below code : Hope you get Best result. If not get back me :) Before posting the code format the code well. You missed some code lines because of it :(
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bottomRelLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/txttxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btnprev"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/arethese"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Are these the property you are looking for? " />
<RelativeLayout
android:id="#+id/loginlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/arethese"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/ifnot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="If not, " />
<TextView
android:id="#+id/txtlogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ifnot"
android:text="login " />
<TextView
android:id="#+id/orcontinue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/txtlogin"
android:text="or continue your " />
<TextView
android:id="#+id/txtsearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/orcontinue"
android:gravity="center_horizontal"
android:text="search " />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/andhave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txttxt"
android:layout_centerHorizontal="true"
android:text="and Have" />
</RelativeLayout>
Textview andhave is out of RelativeLayout element
Put the last TextView with ID "andhave" into the RelativeLayout.
(in your code, above the 2nd </RelativeLayout> I'd say)
Make sure to keep your views in Layouts.
The reason is because your last Textview is outside the main layout.
put all your stuff inside
Ctrl + B ----- to build your project if you made a change in you layout XML. (Eclipse)
Then:
Set setContentView(R.layout.you_xml_file); inside onCreate
Then declare it......
That is
I want to create a listview like older gmail app. See the screenshot:
I tried putting an empty view like this:
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textStyle="bold"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:layout_marginBottom="10dp"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
but this is not taking full height of the view. Please suggest.
What I changed is
android:layout_alignBottom="#+id/number"
to your color_highlight TextView. and instead of margin, I put padding like below in number TextView.
android:paddingBottom="20dp"
just put following layout code.
<?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" >
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/number"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:paddingBottom="20dp"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
</RelativeLayout>
I'm not sure but you can try putting android:layout_height="0dip" instead of android:layout_height="match_parent".
I am trying to reduce the space between 2 columns, have tried using negative margins, but did not work. Is there a way to bring the 2 elements in the image closer ?
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:useDefaultMargins="true"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="false"
android:layout_gravity="center"
android:orientation="horizontal"
android:stretchMode="columnWidth"
android:background="#color/orange"
android:textSize="12sp"
android:columnCount="8">
<ImageButton
android:id="#+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="1"
android:layout_gravity="left"
android:src="#drawable/settings" />
<TextView
android:id="#+id/currentCityName"
android:layout_column="2"
android:textSize="22sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="City name"
android:layout_columnSpan="4"
android:layout_gravity="center_horizontal"
/>
<ImageButton
android:id="#+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="7"
android:layout_columnSpan="1"
android:layout_gravity="right"
android:src="#drawable/reload" />
<ImageView
android:id="#+id/currentWeatherImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="8"
android:layout_rowSpan="3"
android:layout_gravity="center_horizontal"
android:src="#drawable/cloud" />
<ImageView
android:id="#+id/humidityIcon"
android:layout_width="20dp"
android:paddingTop="10dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:layout_marginRight="0dp"
android:layout_gravity="left"
android:background="#000000"
android:src="#drawable/humidity" />
<TextView
android:id="#+id/humidity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:paddingTop="10dp"
android:paddingLeft="0dp"
android:layout_marginLeft="0dp"
android:layout_gravity="left"
android:background="#FFFFFF"
/>
<TextView
android:id="#+id/temperature"
android:layout_columnSpan="4"
android:layout_rowSpan="2"
android:textSize="49sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_gravity="center_horizontal"/>
<ImageView
android:id="#+id/windSpeedIcon"
android:layout_width="30dp"
android:layout_marginRight="1dp"
android:paddingRight="1dp"
android:layout_gravity="right"
android:src="#drawable/wind" />
<TextView
android:id="#+id/windSpeed"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
<!-- android:layout_width="40dp" -->
<TextView
android:id="#+id/precipitationIcon"
android:textSize="28sp"
android:layout_width="40dp"
/>
<TextView
android:id="#+id/precipitation"
android:layout_column="0"
android:textSize="13sp"
android:layout_width="40dp"
/>
<TextView
android:id="#+id/windDirection16Point"
android:textSize="13sp"
android:layout_width="80dp"
android:layout_columnSpan="2"
/>
<TextView
android:id="#+id/weatherDescription"
android:layout_gravity="center_horizontal"
android:layout_row="7"
android:layout_columnSpan="8"/>
<TextView
android:id="#+id/section_label"
android:layout_margin="5dp"
android:layout_columnSpan="8" />
<EditText
android:minLines="4"
android:maxLines="4"
android:id="#+id/edit"
android:layout_columnSpan="8"/>
I suggest implementing the entire view using a RelativeLayout, should be the best solution for the entire view.
You are tackling the wrong problem – you are asking how to reduce the space between columns in a grid layout, but maybe you should’t have used such a layout in the first place!
What you should have been using for your specific layout, is a combination of relative positioning and compound drawables (here, with android:drawableStart).
<?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="80dp"
android:background="#d89018"
android:paddingBottom="4dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="4dp"
>
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="25 ℃"
android:textColor="#fff"
android:textSize="49sp"
/>
<TextView
android:id="#+id/humidity"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:drawableStart="#drawable/humidity"
android:gravity="center_vertical"
android:text="83 %"
android:textColor="#fff"
/>
<TextView
android:id="#+id/windSpeed"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:drawableStart="#drawable/wind"
android:gravity="center_vertical"
android:text="19 km/h"
android:textColor="#fff"
/>
<TextView
android:id="#+id/precipitation"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:drawableStart="#drawable/precipitation"
android:gravity="center_vertical"
android:text="0.1 mm"
android:textColor="#fff"
/>
<TextView
android:id="#+id/windDirection16Point"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="#id/windSpeed"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:drawableStart="#drawable/windDirection"
android:gravity="center_vertical"
android:text="NNW"
android:textColor="#fff"
/>
</RelativeLayout>
Not only this layout is simpler, you also let Android take care of all the spacing for you. To change the spacing between the compound drawable and the text, use android:drawablePadding in the layout’s code above; in Java code, that would be TextView.setCompoundDrawablePadding).
Icons used for the sample: water, windsock, rainy-weather and wind-rose.
I think what's happening is that your Views are being stretched because they are trying to match the width of another view in their columns.
Try decreasing the columnSpan of your Views or separate your layout into two separate GridLayouts.
Or, consider using a different layout altogether. I would recommend RelativeLayout here instead of GridLayout, but I don't know how this fits into a larger window.
try 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="100dp">
<LinearLayout
android:id="#+id/col1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.4"
>
<LinearLayout
android:id="#+id/col1_row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83%"/>
</LinearLayout>
<LinearLayout
android:id="#+id/col1_row2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1.0mm"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/col2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.0"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25'"
android:textSize="50dp"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/col3"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.4"
>
<LinearLayout
android:id="#+id/col3_row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19Km"/>
</LinearLayout>
<LinearLayout
android:id="#+id/col3_row2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NNW"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I think you should change usedefaultMargins to false and give your own margins to the elements.
android:useDefaultMargins="false";
I have this layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/fill_parent"
android:background="#color/white"
android:padding="2dip">
<ImageView
android:id="#+id/img_album"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<LinearLayout
style="#style/fill_parent"
android:orientation="horizontal"
android:layout_toRightOf="#id/img_album"
android:layout_centerVertical="true">
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="10dp"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
/>
</LinearLayout>
</RelativeLayout>
Which gives me this image:
I dont know why I dont get the title of the album and next the number of picts.
Well, I did something using layout_weight property as:
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="10dp"
android:layout_weight="1"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_weight="1" />
And I dont really know why, I get now the number, next to the title, as
Could someone tell me:
Why I dont get the number in the 1st scenario, but I do in the 2nd.
How to expand the text all the width of the Linearyout, so the
second Text "Smartphones..." doesnt get stretch, but fits its
parent.
Thanks!
Using the width = 0dip and weigth = 1. I did it!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/fill_parent"
android:background="#color/white"
android:padding="2dip">
<ImageView
android:id="#+id/img_album"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<LinearLayout
style="#style/fill_parent"
android:orientation="horizontal"
android:layout_toRightOf="#id/img_album"
android:layout_centerVertical="true"
android:id="#+id/album_details">
<TextView
android:id="#+id/album_title"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="30dp"
android:textSize="17sp"
android:layout_weight="1"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_weight="0"
android:textSize="17sp"
android:layout_gravity="right"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</RelativeLayout>
Try to make it with a FrameLayout rather than a RelativeLayout. It's really easier to build your layout with this. Something like this, but with size and style adaptation :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:padding="2dp">
<ImageView
android:id="#+id/img_album"
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_marginRight="6dp"
android:cropToPadding="true"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_gravity="center"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="50dp"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textColor="#color/black"
/>
</FrameLayout>
I have an xml layout that compiles fine but when I used the intent to change to the new view it force closes. I'm almost positive it has to do with my use of table and relative layouts. It's kind of a frankenstien monster of coding, haha. Please let me know if how I can remedy this force close problem. Also, before I had strickly table layout. With this layout it compiled and was fully functional, just not as a pretty. So the java should be fine (theoretically).
CODE:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="#+id/tableLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:background="#FFFFF0">
<RelativeLayout android:orientation="vertical" android:background="#drawable/banner"
android:layout_width="fill_parent" android:layout_height="50sp" android:gravity="center" >
</RelativeLayout>
<RelativeLayout android:id="#+id/tableTitle" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#999">
<TextView android:id="#+id/ListingsTitle" android:text="Title: "
android:textColor="#000" android:textStyle="bold" android:textSize="20sp" />
<TextView android:id="#+id/sellingprice" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#000fff"
android:text="Price:" android:layout_below="#id/ListingsTitle" ></TextView>
<TextView android:id="#+id/mileage" android:layout_below="#id/ListingsTitle" android:layout_toRightOf="#id/sellingprice" android:layout_height="wrap_content" android:text="Mileage:" android:textColor="#000fff" android:layout_width="wrap_content"></TextView>
</RelativeLayout>
<RelativeLayout android:orientation="vertical" android:background="#FFFFF0"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:id="#+id/PhotoGallerybtn"
android:src="#drawable/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"></ImageButton>
<Button android:text="Email the Dealer" android:id="#+id/EmailDealerbtn" android:layout_alignParentLeft="true"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="#id/PhotoGallerybtn"></Button>
<Button android:text="Add to Favs" android:id="#+id/Favsbtn" android:layout_below="#id/PhotoGallerybtn"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="#id/EmailDealerbtn"></Button>
<Button android:text="Share" android:id="#+id/Sharebtn" android:mimeType="image/*"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="#id/PhotoGallerybtn" android:layout_toRightOf="#id/Favsbtn"></Button>
</RelativeLayout>
<TableRow android:id="#+id/tableRow4" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#999">
<TextView android:id="#+id/textName" android:text="Details:"
android:textColor="#000" android:textStyle="bold" android:textSize="20sp" />
</TableRow>
<TextView android:id="#+id/bodystyle" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textColor="#000"
android:text="Body Style:"></TextView>
<TextView android:id="#+id/color" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textColor="#000"
android:text="Color:"></TextView>
<TextView android:id="#+id/doors" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textColor="#000"
android:text="Doors:"></TextView>
<TextView android:id="#+id/engine" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textColor="#000"
android:text="Engine:"></TextView>
<TextView android:id="#+id/vin" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textColor="#000"
android:text="VIN:"></TextView>
</TableLayout>
You should add layout_width and layout_height fields to your TextView with #+id/ListingsTitle id:
<TextView android:id="#+id/ListingsTitle" android:text="Title: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textStyle="bold"
android:textSize="20sp" />