button to be the same size in java code and xml
This is a discussion on button to be the same size in java code and xml within the Droid Development forums, part of the Droid Hacking category; I have a button I created in Xml and that works great.
I am attempting to generate the same button in java code, but I ...
-
button to be the same size in java code and xml
I have a button I created in Xml and that works great.
I am attempting to generate the same button in java code, but I am having trouble.
It seems the button height is larger than the the xml code.
I have tried the Button.setHeight, but it does not seem to have any affect.
Perhaps we need to Inflate the XML.
I have included the Xml and java code.
So, I would like get the java code to match the xml.
login2.xml code...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android
rientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:weightSum="1"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawHorizontalTrack="true">
<LinearLayout android:id="@+id/LinearLayout3"
android
rientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginBottom="4dp"
android:layout_marginRight="4dp" >
<TextView android:id="@+id/text_one"
android:text=""
android:textSize="8pt"
android:textColor="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="5" />
<Button android:id="@+id/ButtonSubmit"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="@drawable/submit"
android
nClick="submitLogin2"
android:layout_weight="5" />
</LinearLayout>
</LinearLayout>
public void mySubmit() {
LinearLayout parent = new LinearLayout(this);
parent.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 0.9f);
LinearLayout child = new LinearLayout(this);
child.setOrientation(LinearLayout.HORIZONTAL);
child.setGravity(Gravity.RIGHT);
child.setPadding(162, 0, 0, 200);
Button b = new Button(this);
b.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT , LayoutParams.FILL_PARENT));
b.setHeight(5);
b.setBackgroundResource(R.drawable.submit);
child.addView(b, lp);
parent.addView(child);
this.setContentView(parent);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(0);
t = new Thread() {
public void run() {
System.exit(0);
}
};
t.start();
}
});
return;
}
-
-
Figured it out... I was able to use just xml.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Similar Threads
-
By brad92 in forum Droid X General Discussions
Replies: 1
Last Post: 06-11-2011, 10:58 AM
-
By BaumbachVcV in forum Droid X Hacks
Replies: 1
Last Post: 02-21-2011, 04:32 PM
-
By Malvado in forum Android App Developers
Replies: 0
Last Post: 09-18-2010, 08:47 PM
-
By J-Buck in forum Off Topic Forum
Replies: 2
Last Post: 08-03-2010, 08:53 AM
-
By triiifashions in forum Motorola Droid
Replies: 0
Last Post: 04-05-2010, 08:18 AM
Search tags for this page
android button same height
,
android button size xml
,
android java button setheight
,
android layout width droid bionic
,
android:layout weight java
,
button size
,
button size java code
,
get the same size button in java
,
java button coding in android
,
java for droid bionic
,
xml button size
Click on a term to search our site for related topics.
Tags for this Thread