sorry for my maybe stupid question, but I am a beginner. I have "relative" square layout and I need insert buttons into this square layout, which relatively changed size and position. These parameters would depend on the dimensions of the square layout. On the first picture is an attempt of square layout, where I would like to put the buttons. On the second picture is demonstrated might look like result. Sry for my english :)
Thank you for your comments.
This is my squarelayout.java
package com.example.squarelayout;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
public class SquareView extends View {
public SquareView(Context context) {
super(context);
}
public SquareView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
setMeasuredDimension(size, size);
}
}
This is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="horizontal"
android:weightSum="100">
<com.example.squarelayout.SquareView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="100"
android:background="#f00"
android:orientation="horizontal" />
</LinearLayout>
</FrameLayout>