Can anyone help me out? I still l don't know what to do. Thx
On Nov 8, 12:56 pm, Wouter Vegter <[email protected]> wrote: > Hello, > > I have defined a view with id "view01" in my xml layout file. I want > to change the height of this view on runtime. At first I wanted to do > it with a single click on the view, but I wasn't able to do that > properly, hence the onClickListener interface. After that i tried to > change the height of the view by hard coding. I didn't succeed. I > have > searched quite a while on internet but so far I haven't found the > right solution. Can someone help me out please? > My .java and .xml file are displayed below. > > Regards, > > Wouter > ***************.java file > package test2.main; > import android.app.Activity; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.LinearLayout; > public class test2 extends Activity implements OnClickListener { > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > View v1 = (View) findViewById(R.id.view01); > v1.setOnClickListener(this); > v1.setMinimumHeight(160); > LinearLayout ll = (LinearLayout) findViewById > (R.id.linearlayout); > ll.requestLayout(); > v1.requestLayout(); > } > public void onClick(View arg0) { > if (arg0.getMeasuredHeight() == 80) > { > arg0.setMinimumHeight(160); > } else > { > arg0.setMinimumHeight(80); > } > arg0.requestLayout(); > } > > } > > **********.xml file > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" android:id="@+id/linearlayout"> > <TableLayout > android:layout_width="fill_parent" > android:layout_height="fill_parent" > android:stretchColumns="0" xmlns:android="http:// > schemas.android.com/apk/res/android"> > <TableRow> > <View > android:layout_height="80px" > android:background="#884400" /> > <TextView android:text="#884400" > android:paddingLeft="4px" > android:layout_gravity="center_vertical" /> > </TableRow> > <TableRow> > <View > android:layout_height="80px" > android:background="#aa8844" android:id="@+id/view01"/> > <TextView android:text="#aa8844" > android:paddingLeft="4px" > android:layout_gravity="center_vertical" /> > </TableRow> > </TableLayout> > </LinearLayout> -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

