بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]
پرسش و پاسخ

کمک در ایجاد parallax scrollview

مدیریت گفتگو
red_sky 11 سال پیش
آخرین تغییر: 11 سال پیش

سلام دوستان

میخوام داخل پروژه از parallax scrollview استفاده کنم راستش اون کتابخونه مدنظر هم از github گرفتم ولی نمیفهمم چطوری باید ازش استفاده کنم کسی میتونه کمکم کنه

این هم لینک اون کتابخونه ای که دانلود کردم

راستش توی ایکلیپس که ایمپرت میکنم کلی ارور میده داخل اندروید استدیو پروژه م را ایمپرت میکنم و این کتابخونه هم طبق روشی که داخل سایت گفته به پروژه ملحق میکنم ولی نمیتونم ازش استفاده کنم یعنی با استفاده از راهنمایی های خودش نتونستم متوجه بشم که دقیقا باید چه کار کنم ممنون میشم کمکم کنید

نظرات

red_sky 11 سال پیش
خواهش میکنم اگه کسی بلده کمک کنه خیلی نیاز دارم به این کار ممنون میشم کمک کنید
omidronaldoo 11 سال پیش
میخوای یه چیزی شبیه به صفحه اطلاعات برنامه دیوار یا دیجی کالا درست کنی؟که با کشیدن صفحه به بالا یا پایین عکس ظاهر و یامیره؟
omidronaldoo 11 سال پیش
اگه اینه بگو تا راهنماییت کنم
red_sky 11 سال پیش
بله ممنون میشم راهنماییم کنید

پاسخ‌ها 2

omidronaldoo 11 سال پیش

اولین چیز اینه که شما باید اندروید استودیو داشته باشین.

دوم sdk اونو آپدیت کنین

بعدش کتابخونه ی    android support design رو به پروژت اضافه کنی.

activity_main.xml

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

<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">


<ImageView
android:id="@+id/backgroundImageView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/tigre"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="parallax"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>








 

نظرات

omidronaldoo 11 سال پیش
تو گوکل جست و جو کنی با زبان انگلیسی بهت میگه چجوری اضافشکنی کتابخونه رو
omidronaldoo 11 سال پیش

my_text_view.xml

 <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
xmlns:tools="http://schemas.android.com/tools"
tools:text="item"
android:textSize="30sp"
android:paddingLeft="10dp"
android:gravity="center_vertical"
android:orientation="vertical">

</TextView>

MainActivity.java

 package tutos.android.collapsingtoolbarlayout;

import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends AppCompatActivity {

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
private String[] myDataset = {"Elem1", "Elem2", "Elem3", "Elem4", "Elem5", "Elem6", "Elem7", "Elem8", "Elem9", "Elem10"};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitle("Titre");
collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));

mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);

mRecyclerView.setHasFixedSize(true);

// use a linear layout manager
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);

mAdapter = new MyAdapter(myDataset);
mRecyclerView.setAdapter(mAdapter);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

MyAdapter.java

 package tutos.android.collapsingtoolbarlayout;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
* Created by nazim on 29/07/15.
*/
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
private String[] mDataset;

// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
public static class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case
public TextView mTextView;
public ViewHolder(TextView v) {
super(v);
mTextView = v;
}
}

// Provide a suitable constructor (depends on the kind of dataset)
public MyAdapter(String[] myDataset) {
mDataset = myDataset;
}

// Create new views (invoked by the layout manager)
@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
TextView v = (TextView) LayoutInflater.from(parent.getContext())
.inflate(R.layout.my_text_view, parent, false);
// set the view's size, margins, paddings and layout parameters
ViewHolder vh = new ViewHolder(v);
return vh;
}


// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
holder.mTextView.setText(mDataset[position]);

}

// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataset.length;
}
}

نظرات

omidronaldoo 11 سال پیش
این یه مثال گوچیک ازشه حساب کار دستت میاد
red_sky 11 سال پیش
وافعا ممنون از راهنماییت و وقتی که گذاشتی

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .