Simple View Question

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Simple View Question

Postby xdm87 » Sun Jan 10, 2010 1:14 am

I want to make this simple horizontal line view within Java using the API. How would I do that?

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <View android:layout_width="fill_parent" android:layout_height="1dp" android:background="?android:attr/listDivider" />
Parsed in 0.000 seconds, using GeSHi

I have this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. View hl = new View(this);
  3. hl.setBackgroundResource(android.R.attr.listDivider);
Parsed in 0.015 seconds, using GeSHi

..but I'm not sure how to set layout_width to fill_parent and layout_height to 1dp.

Posts: 4
Joined: Tue Jan 05, 2010 6:19 am


Re: Simple View Question

Postby jagtap.jj1 » Mon Jan 11, 2010 8:36 am

Which layout r u using?
To set layout params use "LayoutParams" class,
Each layout having corresponding LayoutParams class,
e.g. LinearLayout.LayoutParams: ... arams.html
java-android developer
User avatar
Senior Developer
Senior Developer
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests