Вот такая корявая сетка получилась
Хотелось бы, чтобы буквы и цифры встали ровно, не понимаю, что не так? Пытаюсь, пытаюсь, ничего не получается
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical"
android:weightSum="100"
android:background="#ffffff"
android:paddingRight="50dp"
android:paddingLeft="50dp">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:orientation="vertical">
<include layout="@layout/characters"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/numbers"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:id="@+id/gameTablePlayer1"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_weight="50">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:id="@+id/gameTablePlayer2"/>
</RelativeLayout>
</LinearLayout>
characters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ru.albatros.buttleshit.TextViewSquare
android:layout_width="match_parent"
android:layout_weight="1"
android:gravity="center"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="А"/>
<ru.albatros.buttleshit.TextViewSquare
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#000000"
android:text="B"/>
<ru.albatros.buttleshit.TextViewSquare
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="C"/>
<ru.albatros.buttleshit.TextViewSquare
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="D"/>
<ru.albatros.buttleshit.TextViewSquare
android:gravity="center"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="E"/>
<ru.albatros.buttleshit.TextViewSquare
android:gravity="center"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="F"/>
<ru.albatros.buttleshit.TextViewSquare
android:gravity="center"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="G"/>
<ru.albatros.buttleshit.TextViewSquare
android:gravity="center"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="H"/>
<ru.albatros.buttleshit.TextViewSquare
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="I"/>
<ru.albatros.buttleshit.TextViewSquare
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="J"/>
</LinearLayout>
numbers
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="match_parent">
<ru.albatros.buttleshit.TextViewSquareX
android:layout_width="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="1"/>
<ru.albatros.buttleshit.TextViewSquareX
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="2"/>
<ru.albatros.buttleshit.TextViewSquareX
android:layout_weight="1"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="3"/>
<ru.albatros.buttleshit.TextViewSquareX
android:layout_weight="1"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="4"/>
<ru.albatros.buttleshit.TextViewSquareX
android:gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="5"/>
<ru.albatros.buttleshit.TextViewSquareX
android:gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="6"/>
<ru.albatros.buttleshit.TextViewSquareX
android:gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="7"/>
<ru.albatros.buttleshit.TextViewSquareX
android:gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="8"/>
<ru.albatros.buttleshit.TextViewSquareX
android:layout_weight="1"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="9"/>
<ru.albatros.buttleshit.TextViewSquareX
android:layout_weight="1"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:text="10"/>
</LinearLayout>
TextViewSquare
public class TextViewSquare extends TextView {
public TextViewSquare(Context context) {
super(context);
}
public TextViewSquare(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TextViewSquare(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
TextViewSquareX
public class TextViewSquareX extends TextView {
public TextViewSquareX(Context context) {
super(context);
}
public TextViewSquareX(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TextViewSquareX(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, heightMeasureSpec);
}
}
Добавил пустой TextView
перед буквой А, получилось вот что
characters
иnumbers
растягиваю 10view
, соответственно столбик с цифрами тоже считается как часть и растягивается не по стороне сетки а по стороне сетки + ширина столбца с цифрами. Если делать маргин, то надо знать насколько, а я не знаю, т.к все зависит от экрана