簡體   English   中英

我的布局標記使用帶有 ImageView 和 TextView 的 ScrollView

[英]My layout's markup moves off using ScrollView with ImageView and TextView

我是 Android 開發的新用戶。 其實我有一個問題,我解決不了很長時間。

我有一個帶有 Scroll View 的布局,在這個 ScrollView 中有 ImageView 和 TextView。 你可以在我的代碼中看到它:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity ="center"
        android:fillViewport="true"
        android:id="@+id/scrollView">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageInfo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="fitCenter"
                android:padding="10dp"/>

            <TextView
                android:id="@+id/textInfo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:gravity="center" />

        </LinearLayout>

    </ScrollView>

</LinearLayout> 

我從 JSON 中獲取數據並使用此布局將其輸入。有些圖像具有不同的形式。 所以,請幫我解決這個問題。 我必須用布局標記做什么以及我必須使用什么 scaleType。 提前致謝。

PS對不起我的英語)

如果您也發布了從 json 中獲取數據的代碼,那將會很有幫助。 為了選擇正確的比例類型, 可能會有所幫助。

你好)我已經解決了我的問題。 我只需要添加這些東西

android:scaleType="fitCenter"
android:adjustViewBounds="true"

我只是忘記了 adjustViewBounds 是做什么的)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM