ほんとこれだけ。

package yanzm.example.squarelayoutsample;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class SquareLayout extends FrameLayout {
public SquareLayout(Context context) {
super(context);
}
public SquareLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
<?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"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"
/>
<yanzm.example.squarelayoutsample.SquareLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:layout_weight="1"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="button"
/>
</yanzm.example.squarelayoutsample.SquareLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"
/>
</LinearLayout>
</LinearLayout>
ちなみに、中のボタンは表示されないけどバックグラウンドはADTのレイアウトエディタでも表示されたよ。

0 件のコメント:
コメントを投稿