【问题标题】:How to display four images using coverflow as shown in the attach image link?如何使用coverflow显示四个图像,如附加图像链接所示?
【发布时间】:2014-09-10 16:37:17
【问题描述】:

我是 android 新手,我正在尝试开发应该显示位于可绘制文件夹中的图像的应用程序,如图所示:

请提供有关如何实现此效果的建议。还提供一些适当的链接并解释代码将不胜感激......

【问题讨论】:

  • 这是“我可以用密码吗,普利斯?”的组合。和“让闪亮的图书馆来做我的工作”。你考虑过谷歌搜索吗?
  • 我找到了perfect tutorial here

标签: android eclipse coverflow


【解决方案1】:

这里是CoverFlow Lib for Android


Just download the project and import in eclipse and run

还有Code Example

JAVA 代码

/****
 * The Class CoverFlowTestingActivity.
 */
public class CoverFlowTestingActivity extends Activity {

private TextView textView;

/*
 * (non-Javadoc)
 * 
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        textView = (TextView) findViewById(this.getResources()
                .getIdentifier("statusText", "id", "pl.polidea.coverflow"));
        // note resources below are taken using getIdentifier to allow importing
        // this library as library.
        final CoverFlow coverFlow1 = (CoverFlow)     findViewById(this.getResources().getIdentifier("coverflow", "id",
                "pl.polidea.coverflow"));
        setupCoverFlow(coverFlow1, false);
        final CoverFlow reflectingCoverFlow = (CoverFlow)         findViewById(this.getResources().getIdentifier(
                "coverflowReflect", "id", "pl.polidea.coverflow"));
        setupCoverFlow(reflectingCoverFlow, true);
    }

    /**
     * Setup cover flow.
     * 
     * @param mCoverFlow
     *            the m cover flow
     * @param reflect
     *            the reflect
     */
    private void setupCoverFlow(final CoverFlow mCoverFlow, final boolean reflect) {
        BaseAdapter coverImageAdapter;
        if (reflect) {
        coverImageAdapter = new ReflectingImageAdapter(new ResourceImageAdapter(this));
        } else {
            coverImageAdapter = new ResourceImageAdapter(this);
        }
        mCoverFlow.setAdapter(coverImageAdapter);
        mCoverFlow.setSelection(2, true);
        setupListeners(mCoverFlow);
    }

/**
 * Sets the up listeners.
 * 
 * @param mCoverFlow
 *            the new up listeners
 */
    private void setupListeners(final CoverFlow mCoverFlow) {
        mCoverFlow.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(final AdapterView< ? > parent, final View view, final int position, final long id) {
                textView.setText("Item clicked! : " + id);
            }

        });
        mCoverFlow.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(final AdapterView< ? > parent, final View view, final int position, final long id) {
                textView.setText("Item selected! : " + id);
            }

            @Override
            public void onNothingSelected(final AdapterView< ? > parent) {
                textView.setText("Nothing clicked!");
            }
        });
    }

}

XML

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

<pl.polidea.coverflow.CoverFlow
    xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
    coverflow:imageWidth="100dip" coverflow:imageHeight="150dip" coverflow:withReflection="true"
    coverflow:imageReflectionRatio="0.2" coverflow:reflectionGap="2dip"
    android:id="@+id/coverflowReflect"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_marginTop="5dip" />

<TextView android:text="STATUS" android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:padding="5dip" android:id="@+id/statusText"></TextView>

【讨论】:

  • ..谢谢回复...但是你能告诉我如何在我的项目中实现coverflow库..我以前从未使用过Github...
  • @NadeemIqbal 如果你有一个动态的图片 URL 数组呢?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-06
  • 2017-12-04
  • 2021-01-25
  • 1970-01-01
  • 2015-09-16
  • 1970-01-01
相关资源
最近更新 更多