2012-01-02 43 views
0

由於某種原因,我的圖像按鈕保持重疊。當我使用頂部的滾動視圖時,它正常工作,一切都很好,但我不想向下滾動,看看我點擊了多少次。我只想在屏幕底部顯示文本視圖,而圖像按鈕沒有重疊,我imageButton不斷重疊我想要在屏幕底部的文本視圖

我在做什麼錯? 這是我嘗試新事物

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


    <LinearLayout 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"> 

    <!-- Stretching frame layout using weights will bring it to the bottom --> 


    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/pushme" 
    android:textSize="21sp" 
    android:gravity="center_horizontal|center_vertical" 
    android:textColor="#ff0005" 
    android:background="#ff99ff" 

    /> 



    <Button 
    android:id="@+id/button" 
    android:scaleType="fitCenter" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/push" 


    /> 


<FrameLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_gravity="bottom" 
    android:layout_weight="1" 
    android:layout_below="@+id/numClicked" 
    > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="8dip" 
     android:text="@string/numClicked" 
     android:background="#ffffffff" 
     android:textColor="#ff127223" 

     /> 

    </FrameLayout> 



    </LinearLayout> 

現在這是我使用它使用滾動視圖,但我不想滾動視圖

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"> 
<LinearLayout 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"> 

    <!-- Stretching frame layout using weights will bring it to the bottom --> 


    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/pushme" 
    android:textSize="21sp" 
    android:gravity="center_horizontal|center_vertical" 
    android:textColor="#ff0005" 
    android:background="#ff99ff" 

    /> 



    <Button 
    android:id="@+id/button" 
    android:scaleType="fitCenter" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/push" 


/> 


<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_gravity="bottom" 
    android:layout_weight="1" 

    > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="8dip" 
     android:text="@string/numClicked" 
     android:background="#ffffffff" 
     android:textColor="#ff127223" 

     /> 

+0

您的這些佈局不完整。它沒有顯示你在說什麼。使其正確,否則無法解決它。 – Debarati 2012-01-02 06:54:32

+0

您的佈局中的圖像按鈕在哪裏。老兄,我看不到任何圖像按鈕標籤在那裏.. – AAnkit 2012-01-02 06:55:34

回答

1

試試這個,我不得不改變一些東西在我的模擬器上看到它,但你可以得到它的要點。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<LinearLayout android:layout_width="fill_parent" 
    android:orientation="vertical" android:layout_above="@+id/numClicked" 
    android:layout_height="fill_parent"> 

    <TextView android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:text="pushme" 
     android:textSize="21sp" android:gravity="center_horizontal|center_vertical" 
     android:textColor="#ff0005" android:background="#ff99ff" /> 

    <ImageButton android:src="@drawable/push" 
     android:layout_width="fill_parent" android:id="@+id/button" 
     android:layout_height="wrap_content" android:layout_gravity="center" /> 

</LinearLayout> 

<TextView android:layout_width="fill_parent" android:id="@+id/numClicked" 
    android:layout_height="wrap_content" android:padding="8dip" 
    android:text="numClicked" android:layout_alignParentBottom="true" /> 

</RelativeLayout> 
+0

是的,它確實工作,當我改變它,謝謝 – 2012-01-02 07:02:40

+1

很酷,請點擊接受答案按鈕,以便其他人不會繼續回答 – 2012-01-02 07:05:57

+0

先生它在我的圖形在xml文件中佈局,而不是在電話上 – 2012-01-02 07:27:01

0

//我不明白你的問題?

你可以試試這一次是否這會解決你的問題。

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <!-- Stretching frame layout using weights will bring it to the bottom --> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#ff99ff" 
      android:gravity="center_horizontal|center_vertical" 
      android:text="pushme" 
      android:textColor="#ff0005" 
      android:textSize="21sp" /> 

     <ImageView 
      android:id="@+id/button" 
       android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/apps_icon" 
      android:layout_weight="1" 
      android:scaleType="center" /> 

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

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="#ffffffff" 
       android:padding="8dip" 
       android:text="numClicked" 
       android:textColor="#ff127223" /> 
     </LinearLayout> 
    </LinearLayout> 
+0

是的,它實際上工作時,我改變它,謝謝 其實我剛剛運行它,現在我即將得到一個力量關閉? – 2012-01-02 07:13:36

0

如果我得到它是正確的?你有按鈕那裏..和你設置背景圖像..如果是!然後添加下面的按鈕標籤代替您的佈局中的按鈕標籤..所有最好的

<Button 
android:id="@+id/button" 
android:scaleType="fitCenter" 
android:layout_width="fill_parent" 
android:layout_height="60dp" 
android:layout_marginBottom="10dp" 
android:background="@drawable/push" 


/>