Setting height of TableRow [duplicate]
I have two types of content for TableRow. One has two lines and the other one. I wish everyone had the same height. I'm trying something like this:
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, 80));
Any other ideas? And, how can I transform "80" in dp?
you can set the hight by setting the padding
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
for dynamic
tr.setPadding(0, 12, 0, 12);
You could use two different layouts for the rows and just assign them dynamically in your code. Define the heights in your layouts.
I Solve this with getViewTreeObserver. You must type this method on the tableLayout
AND override onGlobalLayout
.
Inside this method, you can verify all child's height. Then you can identify Max heigh.
精彩评论