Hii guys Я попробовал LinearLayout, внутри которого я разместил несколько текстовых файлов. Я полностью использую веса для каждого вида. Проблема возникает, когда данные становятся слишком длинными, а textview не показывает их полностью. Я также пробовал tabletlayout, но эта вещь также не работает beacuse, в конечном итоге tablelayout находится внутри линейного макета, имеющего вес, поэтому он не выходит за пределы определенного предела. Я хочу знать, как можно прокручивать активность, показывая все данные при использовании весов.Как сделать всю активность прокручиваемой в соответствии с данными внутри нее
ответ
Использование Scrollview в xml Макет вашей деятельности.
Пример: XML-код для вашей деятельности:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/image" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="KNOW MORE" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/description"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>
я говорил об использовании весов полностью и не использовать дп и т.д., когда я использую гири моего TextView имеет ограниченную область show.How я могу сделать такую прокрутку, используя weights.I хотят показать полностраничные прокрученные данные –
Вы можете использовать Scroll View с Linear Layout, а также с относительным макетом.
Вы можете попробовать этот код, просто скопировать и вставить файл XML. U'll получить ваш анс :)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@android:color/black"
>
<TextView
android:id="@+id/TV_Welcome"
android:text="ADD YOUR VEHICLE"
android:layout_marginLeft="70dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_centerHorizontal="true"
android:textColor="@color/menu_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"/>
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_below="@+id/TV_Welcome"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_BlockNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Block No:"
android:textColor="@color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<Spinner
android:id="@+id/Spinner_BlockNo"
android:layout_marginLeft="30dp"
android:layout_toRightOf="@+id/TV_BlockNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_below="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/TV_FlatNo"
android:text="Flat NO:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="@color/version_color"
/>
<Spinner
android:id="@+id/Spinner_FlatNo"
android:layout_marginLeft="42dp"
android:layout_toRightOf="@+id/TV_FlatNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content"></Spinner>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout03"
android:layout_below="@+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_VehicleNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vehicle No:"
android:textColor="@color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<EditText
android:id="@+id/ET_VehicleNo"
android:layout_marginLeft="20dp"
android:hint="Enter Vehicle No"
android:textColorHint="@color/menu_glow"
android:textSize="20dp"
android:layout_toRightOf="@+id/TV_VehicleNo"
android:textColor="#558cff"
android:layout_width="400dp"
android:layout_height="wrap_content"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout04"
android:layout_margin="10dp"
android:layout_below="@+id/RelativeLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/TV_VehicleType"
android:text="Vehicle Type:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="@color/version_color"
/>
<Spinner
android:id="@+id/Spinner_VehicleType"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/TV_VehicleType"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout05"
android:layout_margin="10dp"
android:layout_below="@id/RelativeLayout04"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_OwnerName"
android:text="Owner Name:"
android:textSize="15dp"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="@+id/ET_OwnerName"
android:hint="Enter Owner Name"
android:textColorHint="@color/menu_glow"
android:inputType="textPersonName"
android:layout_marginLeft="20dp"
android:textSize="20dp"
android:layout_toRightOf="@id/TV_OwnerName"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="400dp">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout06"
android:layout_margin="10dp"
android:layout_below="@id/RelativeLayout05"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_MobileNo"
android:text="Mobile No:"
android:textSize="15dp"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="@+id/ET_MobileNo"
android:layout_marginLeft="40dp"
android:hint="Enter 10 digit"
android:textColorHint="@color/menu_glow"
android:inputType="phone"
android:textSize="20dp"
android:layout_toRightOf="@id/TV_MobileNo"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="200dp"
>
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout07"
android:layout_margin="10dp"
android:layout_below="@id/RelativeLayout06"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_TelNo"
android:text="Telephone No:"
android:textSize="15dp"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<EditText
android:id="@+id/ET_TelNo"
android:layout_marginLeft="20dp"
android:hint="Enter Telephone No"
android:textColorHint="@color/menu_glow"
android:inputType="number"
android:textSize="17dp"
android:layout_toRightOf="@id/TV_TelNo"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout08"
android:layout_margin="0dp"
android:layout_below="@id/RelativeLayout07"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TV_Example"
android:text="(Example:0141-2206923)"
android:layout_marginLeft="120dp"
android:textSize="10dp"
android:textColor="@color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
<ImageView
android:id="@+id/ImageView_Submit"
android:layout_marginTop="5dp"
android:layout_marginLeft="100dp"
android:layout_centerInParent="true"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/submit"
android:layout_below="@id/RelativeLayout08"
android:onClick="doSubmit"></ImageView>
</RelativeLayout>
</ScrollView>
Я говорил об использовании весов полностью и не использовал dp и т. д., когда я использую весы, у моего текстового вида есть ограниченная область для показа. Как я могу делать такую прокрутку при использовании весов. Я хочу показать полноразмерные прокрученные данные –
Что высота и ширина, которые вы задали в своем макете. Потому что с layout_weight вы можете указать соотношение размеров между несколькими видами. Например. у вас есть MapView и таблица, которая должна отображать некоторую дополнительную информацию на карте. Карта должна использовать 3/4 экрана, а таблица должна использовать 1/4 экрана. Затем вы установите для layout_weight карты значение 3 и layout_weight таблицы равным 1. Чтобы получить его работу, вы также должны установить высоту или ширину (в зависимости от вашей ориентации) до 0px. –
Надеюсь, это поможет вам, если не thn gv me ваш единственный xml-код, я исправлю этот .... :) :) –
В основном вы должны поместить весь макет XML в целях прокрутки. См. Другие примеры кода.
Я говорил об использовании весов полностью и не использовал dp и т. Д., Когда я использую весы, которые у меня есть ограниченную область для показа. Как я могу выполнять такую прокрутку при использовании весов. Я хочу показать полные страницы с прокруткой данных. –
Вы можете сделать свою деятельность прокручиваемой с помощью ScrollView. Его очень простой и эффективный способ использования. Просто скопируйте код ScrollView снизу и вставьте его в свой XML-файл макета. Вы также можете использовать этот ScrollView с линейным и относительным макетом. Просто нужно помнить одну вещь, ScrollView может иметь только один дочерний виджет. Если вы хотите больше детей, тогда их можно перевернуть в один контейнер.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/xyz.png"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView2"/>
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView3"/>
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView4"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_demo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Demo" />
</LinearLayout>
</LinearLayout>
</ScrollView>
. Я говорил об использовании весов полностью и не использовал dp и т. д., когда я использую весы, у моего текстового обзора есть ограниченная область для показа. могу ли я выполнять такую прокрутку при использовании весов. Я хочу показать полные страницы прокрученных данных. –
@PrashantSinghVerma показать ваш xml, чтобы я мог вам помочь. –
- 1. Как сделать всю страницу прокручиваемой
- 2. Как сделать таблицу прокручиваемой с фиксированным заголовком?
- 3. Как сделать конкретную статическую ячейку в пользовательской настройке UItableview в соответствии с ограничениями содержимого внутри нее
- 4. переименуйте страницу html в соответствии с изображением внутри нее
- 5. Как сделать активность прокручиваемой, даже если ScrollView не требуется?
- 6. Как сделать линейную раскладку прокручиваемой?
- 7. Как сделать следующую активность Android прокручиваемой, если ScrollView не работает?
- 8. Как сделать таблицу прокручиваемой
- 9. Как сделать область в форме выигрыша прокручиваемой?
- 10. Как сделать прокрутку Highslide прокручиваемой?
- 11. Как сделать Uploadify очереди прокручиваемой
- 12. Как сделать страницу gxt прокручиваемой
- 13. Как экспортировать всю базу данных с данными внутри
- 14. Как сделать springmessage с динамическими данными внутри
- 15. Как сделать таблицу прокручиваемой с фиксированным заголовком
- 16. Как сделать таблицу прокручиваемой с фиксированными заголовками
- 17. Сделать табличку прокручиваемой в таблицу
- 18. Как сделать таблицу SWT в CheckboxTableViewer прокручиваемой?
- 19. Как получить всю активность, связанную с событием
- 20. UWP как сделать сетку прокручиваемой в XAML
- 21. Как очистить всю активность в Android?
- 22. Сделать строку таблицы прокручиваемой CSS
- 23. Как сделать мою таблицу прокручиваемой/отзывчивой, если у нее много содержимого, которое не соответствует моему экрану?
- 24. Сделать детали стороной splitViewController прокручиваемой?
- 25. Как сделать прокрутку d3 div прокручиваемой?
- 26. сделать операцию прокручиваемой с помощью двух listView
- 27. Как добавить панель действий во всю активность
- 28. Как переключить активность с конкретными данными, отправленными
- 29. Форматирование связанного элемента управления данными в соответствии с связанными данными
- 30. Как переместить структуру с обещанием внутри нее?
показать свой XML-файл – Destro