我想显示recyclerview的下一个和上一个项目与当前可见项目(如在此第三方库中)相比的部分。但是我设法用我的本地recyclerview做到了。
这对我来说听起来很棒,现在我想将当前可见项目的高度设置为大于下一个和上一个项目的高度,如上述库的gif所示!
在以下阶段,我设法用代码显示了下一个和上一个项目:
1.将recyclerview适配器设置为:
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
locationTypeFragmentBinding.mRecylerview.setLayoutManager(layoutManager);
locationTypeFragmentBinding.mRecylerview.setHasFixedSize(true);
final LocationTypePictureAdapter locationTypePictureAdapter =
new LocationTypePictureAdapter(getActivity(), locationDetails,false);
final SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(locationTypeFragmentBinding.mRecylerview);
locationTypeFragmentBinding.mRecylerview.post(new Runnable() {
@Override
public void run() {
locationTypeFragmentBinding.mRecylerview.
setAdapter(locationTypePictureAdapter);
}
});
Run Code Online (Sandbox Code Playgroud)
2.我在xml中的RecyclerView是:
<android.support.v7.widget.RecyclerView
android:id="@+id/mRecylerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonsHolder"
android:clipToPadding="false"
android:orientation="horizontal"
android:padding="@dimen/_10sdp"
android:paddingStart="@dimen/_15sdp"
android:paddingEnd="@dimen/_15sdp"
android:scrollbarStyle="outsideOverlay"
android:visibility="gone"/>
Run Code Online (Sandbox Code Playgroud)
3.我的RecyclerView项目xml是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp">
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/_5sdp"
android:layout_marginEnd="@dimen/_5sdp"
android:background="@android:color/transparent"
app:cardElevation="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/locationPicture"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout> …Run Code Online (Sandbox Code Playgroud) 我是Java的新手,但需要知道,如果开发人员可以这样做,他/她可以改变它的形状JProgressBar.我的意思是假设在我的情况下我想改变形状,使它看起来像一个圆圈或其他东西?
虽然我只是想将它从条形更改为弧形,或者你可以说我想将条形更改为任何其他形状.我的进度条可能看起来像条形以外的曲线.我想在其中添加一条曲线.
我只是想知道这个线程是否正在中断,如果我做得对吗?如果我错了,请告诉我
public void run(){
int i;
while(!Thread.currentThread().isInterrupted()){
for(i=1;i<=100;i++){
System.out.println("THREAD VALUE AFTER 1 SECOND IS: "+i);
if(i==3){
Thread.currentThread().interrupt();
gotoInform();
break;
}
try{
Thread.currentThread().sleep(1000);////to sleep the Thread for 1 Second (1000ms)
}
catch(Exception e){
System.out.printf("Error"+e);
}
}
}
Run Code Online (Sandbox Code Playgroud)