Problem in XML file

Put your problem here if it does not fit any of the other categories.

Problem in XML file

Postby rmeph » Thu Jan 17, 2008 7:08 pm

In code 2 xml file i used backgound image and on simple image......

first xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8" ?>
  2.  
  3. <LinearLayout
  4.  
  5. android:orientation="vertical"
  6.  
  7. android:layout_width="fill_parent"
  8.  
  9. android:layout_height="wrap_content"
  10.  
  11. android:backgroung="@drawable/img"
  12.  
  13. >
  14.  
  15.  
  16.  
  17. <ImageView
  18.  
  19. android:layout_width="fill_parent"
  20.  
  21. android:layout_height="50dip"
  22.  
  23. android:src="@drawable/shape_1" />
  24.  
  25.  
  26.  
  27. </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


second

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <shape xmlns:android="http://schemas.android.com/apk/res/android">
  4.  
  5. <solid android:color="#00000000"/>
  6.  
  7. <stroke android:width="2dp" android:color="#ff000000"/>
  8.  
  9. <padding android:left="1dp" android:top="1dp"
  10.  
  11. android:right="1dp" android:bottom="1dp" />
  12.  
  13. </shape>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class main extends Activity {
  3.  
  4.     @Override
  5.  
  6.     protected void onCreate(Bundle icicle) {
  7.  
  8.         super.onCreate(icicle);
  9.  
  10.         setContentView(R.layout.main);
  11.  
  12.    }}
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


code run sucessfully.........but background image show half.......where is mistake in code??? :(
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Top

Postby plusminus » Thu Jan 17, 2008 9:51 pm

Hello rmeph,

this probably happens because your surrounding LinearLayout is defined with:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:layout_height="wrap_content"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

and the height of such a LinearLayout is the sum of all its children. So in this case, as you define the Child: ImageView with 'only' 50dip.

Replacign above with this line should do the job.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:layout_height="fill_parent"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Let us know if it helped you :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby rmeph » Fri Jan 18, 2008 2:19 pm

thanks a lots......it's working........
1 more problem

in xml file i used Imageview

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <ImageView id="@+id/image"
  2.  
  3.       android:layout_width="300dip"
  4.  
  5.       android:layout_height="80dip"
  6.  
  7.        android:layout_marginTop="10dip"
  8.  
  9.        android:layout_marginLeft="10dip"
  10.  
  11.       android:src="@drawable/shape_1"
  12.  
  13.        />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


in shape_1.xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <shape xmlns:android="http://schemas.android.com/apk/res/android" type="rectangle">
  2.  
  3.     <gradient android:startColor="#FFFFFF" android:endColor="#FFFFFF"
  4.  
  5.            android:angle="270"/>
  6.  
  7.    <padding android:left="40dp" android:top="40dp"
  8.  
  9.           android:right="40dp" android:bottom="40dp" />
  10.  
  11.     <corners android:radius="20dp" />
  12.  
  13. </shape>
  14.  
  15.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


i want used image on imageview.i used in main.java

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.  
  3.         super.onCreate(icicle);
  4.  
  5.          
  6.  
  7.         setContentView(R.layout.main);
  8.  
  9.        ImageView iv = (ImageView)findViewById(R.id.image);
  10.  
  11.         iv.setImageDrawable(getResources().getDrawable(R.drawable.x));
  12.  
  13.       iv.invalidate();
  14.  
  15.          }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


but it show only image not show background rectangle(shape_1.xml).....how to use both?i also try

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <org.android.main  id="@+id/image"
  2.  
  3.       android:layout_width="300dip"
  4.  
  5.       android:layout_height="80dip"
  6.  
  7.        android:layout_marginTop="10dip"
  8.  
  9.        android:layout_marginLeft="10dip"
  10.  
  11.       android:src="@drawable/shape_1"
  12.  
  13.        />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


but it's not working......1 more question i want write some text on rectangle....how to write that? :roll:
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Postby rmeph » Sat Jan 19, 2008 11:11 am

:roll:
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Postby plusminus » Sat Jan 19, 2008 1:36 pm

Hello rmeph,

this line:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. iv.setImageDrawable(getResources().getDrawable(R.drawable.x));
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

"overrides" what you defined in your xml.
Both functions you used are equivalent.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:src="@drawable/shape_1"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

I don't know, if android:background is possible on ImageView, you should test that.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:background="@drawable/shape_1"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby rmeph » Sat Jan 19, 2008 2:06 pm

thanks for reply.......

In your "A android.widget.Gallery - Example" on focus image i want some flashing light effect near a image...is it possible.....if yes,then what API will we use??? :roll:
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests