现在我正在使用此封面流:https://github.com/davidschreiber/FancyCoverFlow
我已经很好地运行了代码,但我需要让我的项目看起来有点像这样:
这条红线就像是:
我想在这个形状中添加图像。我怎么能这样做?
这是我的代码:
MainActivity.java:
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import at.technikum.mti.fancycoverflow.FancyCoverFlow;
import at.technikum.mti.fancycoverflow.FancyCoverFlowAdapter;
public class MyAdapter extends FancyCoverFlowAdapter {
private int[] images = {R.drawable.rain,R.drawable.rain2,R.drawable.rain_forest,
R.drawable.rain,R.drawable.rain2,R.drawable.rain_forest};
private String[] nameImage = {"Rain1", "Rain2", "Rain3", "Rain4", "Rain5", "Rain6"};
private Context mContext;
public MyAdapter(Context mContext){
this.mContext=mContext;
}
@Override
public int getCount() {
return images.length;
}
@Override
public Integer getItem(int i) {
return images[i];
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getCoverFlowItem(int i, View reuseableView, ViewGroup viewGroup) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
reuseableView = inflater.inflate(R.layout.custom_layout, viewGroup, false);
RelativeLayout rlMain =(RelativeLayout) reuseableView.findViewById(R.id.rlMain);
rlMain.setLayoutParams(new FancyCoverFlow.LayoutParams(400,400));
TextView txtName = (TextView) reuseableView.findViewById(R.id.txtNameimage);
ImageView ivImage = (ImageView) reuseableView.findViewById(R.id.imageView);
txtName.setText(nameImage[i]);
ivImage.setImageResource(images[i]);
return reuseableView;
}
}
MyAdapter.java:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fcf="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/rain_forest"
android:id="@+id/backgroundlayout">
<at.technikum.mti.fancycoverflow.FancyCoverFlow
android:id="@+id/fancyCoverFlow"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
fcf:maxRotation="80"
fcf:unselectedAlpha="0.3"
fcf:unselectedSaturation="0.0"
fcf:unselectedScale="0.4"
fcf:scaleDownGravity="0.5"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
activity_main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/txtNameimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Tên ảnh"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
和custom_layout.xml:
brew install openssl
答案 0 :(得分:0)
我已经使用Photoshop解决了这个问题。我认为在这种情况下使用photoshop比其他方式更简单。