2015-03-13 69 views
0
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    > 
<LinearLayout 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    android:orientation="vertical" 
    android:background="@drawable/divisionwise" 
    tools:context="historical.com.example.ahmed.historicalplacesbd.Division"> 

    <ImageButton 
     android:id="@+id/dhaka" 
     android:layout_width="240dp" 
     android:layout_height="70dp" 
     android:layout_marginTop="20dp" 
     android:layout_gravity="center" 
     android:background="@drawable/divisionbtnone"/> 
    <ImageButton 
     android:id="@+id/chittagong" 
     android:layout_width="240dp" 
     android:layout_height="70dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/chitta"/> 
    <ImageButton 
     android:id="@+id/sylhet" 
     android:layout_width="240dp" 
     android:layout_height="70dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/sylh"/> 
    <ImageButton 
     android:id="@+id/khulna" 
     android:layout_width="240dp" 
     android:layout_height="60dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/khuln" 
     /> 
    <ImageButton 
     android:id="@+id/rajshahi" 
     android:layout_width="240dp" 
     android:layout_height="70dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/raj"/> 
    <ImageButton 
     android:id="@+id/barishal" 
     android:layout_width="240dp" 
     android:layout_height="70dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/bari"/> 
    <ImageButton 
     android:id="@+id/rangpur" 
     android:layout_width="240dp" 
     android:layout_height="60dp" 
     android:layout_marginTop="10dp" 
     android:layout_gravity="center" 
     android:background="@drawable/rangpor" 
     /> 

</LinearLayout> 
</ScrollView> 

添加滚动视图我用这个代码加在我的XML滚动型file.but我在输出我得到一个白色的屏幕,这需要一些地方我的形象和按钮。喜欢这个。麻烦在Android Studio中

enter image description here

现在

我怎么能删除时,我模仿我的app.i希望我的形象和其他属性,以我的应用程序的屏幕

+0

的LinearLayout中的滚动型里面应该有layout_height =“WRAP_CONTENT” – cyroxis 2015-03-13 13:26:11

+0

只要把滚动型线性布局 – Apurva 2015-03-13 13:38:56

+0

内题外话,但我把按钮放在一个数据库驱动的列表视图,因此该应用可以很容易地修改为与其他地方一起工作。 – danny117 2015-03-13 14:09:42

回答

0

为了使IMAG E要全屏请使用android:background="@drawable/divisionwise" in scroll view instead of LinearLayout.

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
android:background="@drawable/divisionwise" 
    > 
    <LinearLayout 
     xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:orientation="vertical" 

     tools:context="historical.com.example.ahmed.historicalplacesbd.Division"> 
    </LinearLayout> 
    </ScrollView> 
+0

非常感谢穷人..工作!!!!!! – SharminArshi 2015-03-13 13:45:27

+1

也许在你的ScrollView中添加android:fillViewport =“true”会有所帮助。 (而不是设置背景ScrollView) – PaMaDo 2015-03-13 13:51:24

+0

谢谢大家! – SharminArshi 2015-03-13 15:01:04

0

上呈现增加scrollview作为一个孩子所产生的额外的空白空间到容器父linearlayout

添加像下面

<LinearLayout xmlns:tools="http://schemas.android.com/tools" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/divisionwise" 
    android:orientation="vertical" 
    tools:context="historical.com.example.ahmed.historicalplacesbd.Division" > 

<ScrollView 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    > 
<ImageButton 
    android:id="@+id/dhaka" 
    android:layout_width="240dp" 
    android:layout_height="70dp" 
    android:layout_marginTop="20dp" 
    android:layout_gravity="center" 
    android:background="@drawable/divisionbtnone"/> 
<ImageButton 
    android:id="@+id/chittagong" 
    android:layout_width="240dp" 
    android:layout_height="70dp" 
    android:layout_gravity="center" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/chitta"/> 
<ImageButton 
    android:id="@+id/sylhet" 
    android:layout_width="240dp" 
    android:layout_height="70dp" 
    android:layout_gravity="center" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/sylh"/> 
<ImageButton 
    android:id="@+id/khulna" 
    android:layout_width="240dp" 
    android:layout_height="60dp" 
    android:layout_gravity="center" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/khuln" 
    /> 
<ImageButton 
    android:id="@+id/rajshahi" 
    android:layout_width="240dp" 
    android:layout_height="70dp" 
    android:layout_gravity="center" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/raj"/> 
<ImageButton 
    android:id="@+id/barishal" 
    android:layout_width="240dp" 
    android:layout_height="70dp" 
    android:layout_gravity="center" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/bari"/> 
<ImageButton 
    android:id="@+id/rangpur" 
    android:layout_width="240dp" 
    android:layout_height="60dp" 
    android:layout_marginTop="10dp" 
    android:layout_gravity="center" 
    android:background="@drawable/rangpor" 
    /> 
</ScrollView> 
</LinearLayout> 
+0

感谢卡兰梅尔..我试过这个..但这是产生渲染问题的错误。 – SharminArshi 2015-03-13 13:40:35

+0

你正在设计什么api – 2015-03-13 13:42:52

+0

更新了答案现在就来看看吧 – 2015-03-13 13:45:40