Как создать квадратный TableLayout содержащий 100 ImageView?
Добавлено: 01 июл 2014, 20:59
Здравствуйте уважаемые Специалисты!
Уже 2 недели ищу в интернете информацию и ничего нет.
У меня такой вопрос: есть 100 ImageView с квадратными картинками, картинки берутся из папок drawable соответственно dpi устройства и масштабируются во всех ImageView так как у каждого ImageView и у каждого tableRow установлено (android:layout_weight="1").
Вот фрагмент xml кода:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
android:orientation="vertical"
android:weightSum="100" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="10"
android:gravity="center_vertical|center_horizontal"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="80"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="15"
android:gravity="center_vertical|center_horizontal"
android:text="TextView" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="70" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
<ImageView
android:id="@+id/imageView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
<ImageView
android:id="@+id/imageView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
и так далее.
Вот как это выглядит на эмуляторе с экраном 480х800:
а вот так на эмуляторе с экраном 2560х1600:
как сделать так, чтобы TableLayout был бы квадратным (вторая картинка) на всех разрешениях всех устройств. Ну или квадратный FrameLayout а уже в него вложен TableLayout занимающий всю площадь квадратного FrameLayout.
Заранее благодарен за помощь!!!
Прошу так-же привести пример кода!
С уважением!
Уже 2 недели ищу в интернете информацию и ничего нет.
У меня такой вопрос: есть 100 ImageView с квадратными картинками, картинки берутся из папок drawable соответственно dpi устройства и масштабируются во всех ImageView так как у каждого ImageView и у каждого tableRow установлено (android:layout_weight="1").
Вот фрагмент xml кода:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
android:orientation="vertical"
android:weightSum="100" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="10"
android:gravity="center_vertical|center_horizontal"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="80"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="15"
android:gravity="center_vertical|center_horizontal"
android:text="TextView" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="70" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
<ImageView
android:id="@+id/imageView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
<ImageView
android:id="@+id/imageView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:src="@drawable/a" />
и так далее.
Вот как это выглядит на эмуляторе с экраном 480х800:
а вот так на эмуляторе с экраном 2560х1600:
как сделать так, чтобы TableLayout был бы квадратным (вторая картинка) на всех разрешениях всех устройств. Ну или квадратный FrameLayout а уже в него вложен TableLayout занимающий всю площадь квадратного FrameLayout.
Заранее благодарен за помощь!!!
Прошу так-же привести пример кода!
С уважением!