1

的頂部,我想創建一個廣告橫幅其顯示在屏幕的底部,並在屏幕的頁面,除了旗幟滾動。旗幟不斷停留在底部。佈局元素:一個在另一個

所以,我需要一個<ScrollView>元素,我需要一個<LinearLayout>元素位於<ScrollView>的頂部。並位於屏幕的底部

如何在Android中實現廣告橫幅佈局? (我正在開發Android 2.1 API 7應用程序),有人可以給我一些提示嗎?

** * ***UPDATE* ** * **

我想通了使用<FrameLayout>,但仍然有興趣聽聽其他人的意見。

+0

FrameLayout是最簡單的方法。下面的其他答案太複雜了。 – wnafee 2012-02-16 02:54:00

回答

1

你有另一種選擇(和簡單得多我猜)是使用這種類型的佈局:

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

    <ScrollView> 
     //here is the scroll 
    </ScrollView> 

    <LinearLayout android:layout_alignParentBottom="true"> 
     // here is the ad 
    </LinearLayout> 

</RelativeLayout> 
1

我看到一些方法來做到這一點。

1簡單使用Activity.addContentView()爲活動添加額外的內容視圖。

  • 廣告不是從主要佈局

2使用android:layout_alignParentBottom依賴作爲建議slukian

  • 你的廣告依賴從主要佈局

3創建包含廣告自己的視圖類。在方法onDraw()調用:canvas.drawBitmap(bitmap, posX, posY, null);。 posX,posY - 是絕對位置。然後按照方式1將您的視圖添加到主佈局。

相關問題