2017-08-15 149 views
1

我是android新手。水平滾動查看和佈局 - Android

我想圖像按鈕上的圖像的頂部在一個水平滾動視圖(橫向模式電話)的網格,使得在網格視圖滾動背景圖像和圖像按鈕一起

我想是這樣相對佈局,水平滾動視圖,線性佈局(具有背景圖像),gridview(具有圖像按鈕的行和列)

我似乎無法覆蓋圖像頂部的圖像按鈕在gridview。它似乎工作,如果我把一個圖像按鈕的線性佈局,但我需要他們在網格中。我如何去做這件事?在此先感謝

如果我嘗試把圖像按鈕,網格視圖,我得到渲染錯誤: addView(查看,的LayoutParams)在適配器的觀點是不支持

也許我應該使用網格佈局?

Build.gradle (Module:app) 
apply plugin: 'com.android.application' 

android { 
compileSdkVersion 26 
buildToolsVersion "26.0.0" 
defaultConfig { 
    applicationId "com.example.tim.myapplication" 
    minSdkVersion 16 
    targetSdkVersion 26 
    versionCode 1 
    versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner. 
AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile 
('proguard- android.txt'), 'proguard-rules.pro' 
    } 
    } 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:26.+' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:gridlayout-v7:25.3.1' 
} 
+0

認爲吉他指板的圖像,並試圖添加按鈕的字符串。謝謝 – Tim

回答

1

這個問題還不清楚,試着上傳一張所需佈局的圖片。

無論如何,我可以建議你使用水平線性佈局作爲父母,並在那添加垂直相對佈局,這樣你就可以在一邊有一個按鈕,在另一邊有圖像。

+0

想象吉他指板的圖像,並嘗試向琴絃添加按鈕。謝謝 – Tim

+0

然後你可以有一個線性佈局作爲父母,並有多個線性佈局作爲相反方向的孩子,你可以在每個人都有音符符號。 –

+0

上面的答案可以是確切的答案,因爲您期待吉他琴絃 –