小编Nad*_*din的帖子

Gridlayout 中的 TextView 出现在屏幕外

我正在创建一个 android 应用程序,用于显示我所在城市可用的所有服务的联系方式。我在我的应用程序中使用抽屉来导航城市。但是具有较长文本(例如地址)的 TextView 会出现在屏幕之外。所以请帮助我让 TextView 适合屏幕。以下是我为该活动编写的代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Name: "
    android:id="@+id/textView27"
    android:layout_row="0"
    android:layout_column="0"
    style="@style/Base.TextAppearance.AppCompat.Title"
    android:textSize="22dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Idea Gallery"
    android:id="@+id/textView28"
    android:layout_row="0"
    android:layout_column="1"
    android:textSize="22dp" />

<TextView
    style="@style/Base.TextAppearance.AppCompat.Title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Address: "
    android:id="@+id/textView29"
    android:layout_row="1"
    android:layout_column="0"
    android:textSize="22dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Shop No 5, Akshay Apartment, Kalwa, Thane - 400605, Opposite Pramila Hospital "
    android:id="@+id/textView30"
    android:layout_row="1"
    android:layout_column="1"
    android:textSize="22dp" />

<TextView
    style="@style/Base.TextAppearance.AppCompat.Title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Contact:"
    android:id="@+id/textView31"
    android:layout_row="2"
    android:layout_column="0" …
Run Code Online (Sandbox Code Playgroud)

android android-layout

6
推荐指数
2
解决办法
879
查看次数

标签 统计

android ×1

android-layout ×1