導航:首頁 > 操作系統 > android畫廊

android畫廊

發布時間:2022-01-17 04:50:45

1. android,設計畫廊滾動條,三張圖片,一張圖片佔1/3滾動條,如圖所示,最好使用HorizontalScrollView

<HorizontalScrollView
android:layout_width="200dp"
android:layout_height="fill_parent">
<ListView
android:layout_width="400dp"
android:layout_height="fill_parent"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:scrollingCache="false"
/>
</HorizontalScrollView>

2. android怎麼以畫廊效果顯示本機中的某幾張圖片

http://blog.csdn.net/sharme/article/details/7417755
這是教程.

3. Android 畫廊怎麼讓第一張圖在最左邊

下面上代碼,相關解釋都放在代碼里了。
1、建立一個新項目HelloGallery。
2、拷貝wallpaper_0.jpg…wallpaper_9.jpg 10個圖片文件到res/drawable目錄。
3、res/layout/main.xml文件的內容如下:
XML/HTML代碼
<?xml version="1.0" encoding="utf-8"?>
<framelayout android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/FrameLayout01">
<imageview android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/ImageView01" android:src="@drawable/wallpaper_0">
</imageview>

<gallery android:layout_height="wrap_content" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Gallery01" android:spacing="5dp">
</gallery>
</framelayout>
其中我們使用FrameLayout來實現疊加效果,使用ImageView來顯示大圖,Gallery來展示畫廊,android:spacing="5dp" 屬性則是用來設置元素之間的間隔。
4、在res/values/目錄中新建一個attrs.xml內容如下:
XML/HTML代碼
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare -styleable="" name="HelloGallery">
<attr name="android:galleryItemBackground">
</attr></declare>
</resources>
5、在MainHelloGallery.java中的內容如下:
Java代碼
package android.basic.lesson13;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

public class MainHelloGallery extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//定義UI組件
final ImageView iv= (ImageView)findViewById(R.id.ImageView01);
Gallery g = (Gallery) findViewById(R.id.Gallery01);

//設置圖片匹配器
g.setAdapter(new ImageAdapter(this));

//設置AdapterView點擊監聽器,Gallery是AdapterView的子類
g.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//顯示點擊的是第幾張圖片
Toast.makeText(MainHelloGallery.this, "" + position,
Toast.LENGTH_LONG).show();
//設置背景部分的ImageView顯示當前Item的圖片
iv.setImageResource(((ImageView)view).getId());
}
});
}

//定義繼承BaseAdapter的匹配器
public class ImageAdapter extends BaseAdapter {

//Item的修飾背景
int mGalleryItemBackground;

//上下文對象
private Context mContext;

//圖片數組
private Integer[] mImageIds = { R.drawable.wallpaper_0,
R.drawable.wallpaper_1, R.drawable.wallpaper_2,
R.drawable.wallpaper_3, R.drawable.wallpaper_4,
R.drawable.wallpaper_5, R.drawable.wallpaper_6,
R.drawable.wallpaper_7, R.drawable.wallpaper_8,
R.drawable.wallpaper_9 };

//構造方法
public ImageAdapter(Context c){
mContext = c;
//讀取styleable資源
TypedArray a = obtainStyledAttributes(R.styleable.HelloGallery);
mGalleryItemBackground = a.getResourceId(
R.styleable.HelloGallery_android_galleryItemBackground, 0);
a.recycle();

}

//返回項目數量
@Override
public int getCount() {
return mImageIds.length;
}

//返回項目
@Override
public Object getItem(int position) {
return position;
}

//返回項目Id
@Override
public long getItemId(int position) {
return position;
}

//返回視圖
@Override
public View getView(int position, View convertView, ViewGroup parent) {

ImageView iv = new ImageView(mContext);
iv.setImageResource(mImageIds[position]);
//給生成的ImageView設置Id,不設置的話Id都是-1
iv.setId(mImageIds[position]);
iv.setLayoutParams(new Gallery.LayoutParams(120, 160));
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setBackgroundResource(mGalleryItemBackground);
return iv;
}

}
}

4. android的畫廊功能怎麼寫

使用Gallery,實際上是一個圖片列表,搭配BaseAdapter實現View重用,但是要注意BitmapFactory.decodeFile()的oom問題。

5. android中如何讓畫廊連續不間斷的滑動

給適配器裡面的getCount返回一個integer.max,然後自己定義在getview當position到數據最後時怎麼做,簡單的辦法是用position%真實數據長度得到余數就是應該顯示的圖片的position

6. Android畫廊Gallery求解,不是很明白,代碼如下:

這是一個adapter,具體使用方法網路一下,很詳細的。

getCount 就是獲取這個gallery裡面有的圖片view的個數。

getItem方法感覺寫的不對,應該是返回mImageIds[position]
getView方法是返回一個view,即position處的view,這個方法裡面初始化了一個imageview對象,設置了該imageview的背景圖片,圖片的資源id即為數組中保存的position處的值。然後設置了圖片的layoutparams。最後返回這個圖片。這樣用戶就可以看到這個圖片了。

望採納

7. android點擊畫廊某張圖片,目的使整個畫廊放大,所點擊的圖片仍放中間,這個效果怎麼設置

雙擊圖片就可以了

8. android畫廊怎樣做出超炫效果

首先來看下面的效果:

從上面的圖片可以看到,當添加多張圖片的時候,能夠在下方形成一個畫廊的效果,我們左右拉動圖片來看我們添加進去的圖片,效果是不是好了很多呢?下面來看看怎麼實現吧!


上面的效果類似Android裡面ViewPage的效果,但是跟ViewPager有所不同,ViewPager每次只能顯示一張圖片。


其實我們是利用到了View的clipChildren屬性,我們在這里要把ViewPager以及它的父窗體都設置為false,如下:


android:clipChildren="false"


因為如果clipChildren屬性設置為true,就表明我們要將children給clip掉,就是說對於子元素來說,超出當前view的部分都會被切掉,那我們在這里把它設置成false,就表明超出view的部分,不要切掉,依然顯示。


xml代碼部分:


<!-- 配置container和pager的clipChildren=false, 並且指定marginLeft 和 marginRight 的值-->


<LinearLayout

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="100dp"

android:clipChildren="false"

android:gravity="center_horizontal"

android:layerType="software"

android:orientation="horizontal" >

<android.support.v4.view.ViewPager

android:id="@+id/viewpager"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_marginLeft="110dp"

android:layout_marginRight="110dp"

android:clipChildren="false" >

</android.support.v4.view.ViewPager>

</LinearLayout>


Java代碼部分:


// 1.設置幕後item的緩存數目

mViewPager.setOffscreenPageLimit(3);

// 2.設置頁與頁之間的間距

mViewPager.setPageMargin(10);

// 3.將父類的touch事件分發至viewPgaer,否則只能滑動中間的一個view對象

container.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

return mViewPager.dispatchTouchEvent(event);

}

});

9. 在android系統 里的 gallery什麼意思啊

android系統里的「gallery」指的是圖庫相冊。

gallery 表示:n. 畫廊;走廊;旁聽席;地道;vt. 在…修建走廊;在…挖地道;vi. 挖地道

相關短語

1、art gallery美術館;畫廊

2、photo gallery圖片庫

3、picture gallery畫館;美術館

(9)android畫廊擴展閱讀:

近義詞:n. 畫廊;走廊;旁聽席;地道 hall、passage、corridor、underground、subway

gallery 來自拉丁語Galilaea, 現巴勒斯坦地名Galilee,原指位於Galilee的教堂門廊,走廊。

雙語例句

1、Beforewego tothegallery.

在我們去畫廊之前。

2、Isthisyourgallery?

這是你的畫廊嗎?

3、Sowhat diddadhave todo at thegallery.

那麼其實爸爸要去畫廊做什麼?

閱讀全文

與android畫廊相關的資料

熱點內容
手機時間如何校正到伺服器 瀏覽:81
創造與魔法瞬移源碼百度 瀏覽:882
反射優化java 瀏覽:874
硬體加密播放盒子 瀏覽:923
xp點擊文件夾選項沒反應 瀏覽:537
蘋果不顯示桌面的app怎麼刪除 瀏覽:864
安卓手機怎麼換國際服 瀏覽:415
神獸領域安卓怎麼下載 瀏覽:250
單片機交通燈ad原理圖 瀏覽:413
多功能解壓磁鐵筆 瀏覽:80
少兒編程火箭升空 瀏覽:401
蘭斯10游戲解壓碼 瀏覽:42
手機proxy伺服器地址 瀏覽:449
吉他清音壓縮 瀏覽:301
簡歷模板程序員 瀏覽:882
螺桿壓縮機虛標型號 瀏覽:953
idea開發項目伺服器ip地址 瀏覽:125
串口伺服器出現亂碼怎麼解決 瀏覽:950
命令按鈕的default 瀏覽:161
戰網如何登錄其他伺服器 瀏覽:990