Yerleşimimi nasıl aşağı kaydırabilirim?


92

"Yanıtlayan:" bölümündeki verileri görüntülemek için ekranı aşağı kaydıramıyorum. Düzenimi nasıl kaydırılabilir hale getirebilirim?

alternatif metin

Yanıtlar:


203

Sadece hepsini bir içine sarın ScrollView:

<?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">
    <!-- Here you put the rest of your current view-->
</ScrollView>

David Hedlund'un dediği gibi, ScrollView yalnızca bir öğe içerebilir ... yani eğer böyle bir şeye sahipseniz:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <!-- bla bla bla-->
</LinearLayout>

Bunu şu şekilde değiştirmelisiniz:

<?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">
    <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <!-- bla bla bla-->
    </LinearLayout>
</ScrollView>

16
+1. hızlı bir not: a ScrollViewyalnızca bir çocuk içerebilir, bu nedenle şu anda sahip olduğunuz çok sayıda görüntü varsa, bunları tek bir görüntüleme grubuna bağlamanız gerekir (a diyelim LinearLayout)
— David Hedlund

benim sorunum lütfen yardım nasıl düzeltileceği bana stackoverflow.com/questions/38588702/...
— Karthi

41

Göreli düzen ile birlikte kaydırma görünümünü kullanmak için:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/background_image"
    >

    <!-- Bla Bla Bla i.e. Your Textviews/Buttons etc. -->
    </RelativeLayout>
</ScrollView>


4

Hepsini bir ScrollView içine sarın

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ruatech.sanikamal.justjava.MainActivity">
<!-- Here you put the rest of your current view-->
</ScrollView>

1

Evet, çok basit. Kodunuzu bunun içine koyun:

<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">

//YOUR CODE

</androidx.core.widget.NestedScrollView>

0

Yukarıda yazılanları yaptıktan sonra kaydırma bile almadıysanız .....

Set android:layout_height="250dp"ya diyebilirsiniz xdpnereye xherhangi bir sayısal değer olabilir.

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.