2016-02-17 15 views
9

Cho phép làm điều gì đó challanging. Tôi đã thấy hoạt ảnh này cho ngăn điều hướng: enter image description hereHoạt ảnh tùy chỉnh cho ngăn điều hướng mở và đóng

và tôi muốn thực hiện điều này vì đây là một hiệu ứng tuyệt vời. Tôi đã cố gắng để có được hiệu quả bằng cách tạo ra một cái nhìn tùy chỉnh và liên lạc tôi đang nhận được ít nhất 50% hiệu ứng tương tự. tôi muốn thực hiện các phương thức ondraw() và ontouch() từ chế độ xem tùy chỉnh của tôi sang chế độ xem điều hướng. Làm thế nào là thực hiện? Bất kỳ ai có bất kỳ đầu mối? Bất cứ ai có thể cung cấp cho bất kỳ liên kết có công cụ simlar.

Tôi đã thử này:

public class CustomNavigation extends DrawerLayout { 

    public CustomNavigation(Context context) { 
     super(context); 
    } 

    public CustomNavigation(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public CustomNavigation(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
//  invalidate(); 
    } 
    public void start() 
    { 
     this.invalidate(); 
     Log.d("Parth", "start"); 
    } 

    @Override 
    public void onDraw(Canvas c) { 
     Log.d("Parth", "ondraw"); 
//  super.onDraw(c); 

    } 

} 

Các phương pháp bốc thăm không được gọi. tại sao vậy?

từ hoạt động chính tôi làm cho một đối tượng của lớp trên và gọi phương thức start như thế này:

CustomNavigation drawer = (CustomNavigation) findViewById(R.id.drawer_layout); 
drawer.start(); 

và đây chỉ là những thứ ban đầu, tôi cũng muốn thực hiện sau đây:

+0

Hi bất kỳ ai có ý tưởng làm thế nào để đạt được bấm vào mục danh sách xem và mở một trang chi tiết hoạt hình như hình ảnh trên, Giúp đánh giá cao Cảm ơn Advance – KeTaN

Trả lời

5

Vì vậy, cuối cùng sau khi tìm thấy rất nhiều tôi tìm thấy một thư viện cho việc này, và đây là link với nó. Tôi không biết tại sao nó lại khó tìm đến thế. Hoặc nó chỉ là tuần tồi tệ của tôi dù sao cho những người muốn sử dụng nó, bạn sẽ có thể tìm thấy thư viện ở đây. và nhiều hơn tôi cũng sẽ cung cấp cho việc thực hiện nếu bạn cần nó:

main_activity.xml

<?xml version="1.0" encoding="utf-8"?> 
<com.mxn.soul.flowingdrawer_core.LeftDrawerLayout 
    android:id="@+id/id_drawerlayout" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clipChildren="false" 

    > 

    <!--content--> 
    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
    </android.support.design.widget.CoordinatorLayout> 

    <!--menu--> 
    <RelativeLayout 
     android:layout_width="280dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:clipChildren="false" 
     > 
     <com.mxn.soul.flowingdrawer_core.FlowingView 
      android:paddingRight="35dp" 
      android:id="@+id/sv" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
     <FrameLayout 
      android:id="@+id/id_container_menu" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_marginRight="25dp" 

      /> 
    </RelativeLayout> 

</com.mxn.soul.flowingdrawer_core.LeftDrawerLayout> 

Main_activity.java

public class MainActivity extends AppCompatActivity{ 

    private LeftDrawerLayout mLeftDrawerLayout; 

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

     mLeftDrawerLayout = (LeftDrawerLayout) findViewById(R.id.id_drawerlayout); 

     FragmentManager fm = getSupportFragmentManager(); 
     MyMenuFragment mMenuFragment = (MyMenuFragment) fm.findFragmentById(R.id.id_container_menu); 
     FlowingView mFlowingView = (FlowingView) findViewById(R.id.sv); 
     if (mMenuFragment == null) { 
      fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment = new MyMenuFragment()).commit(); 
     } 
     mLeftDrawerLayout.setFluidView(mFlowingView); 
     mLeftDrawerLayout.setMenuFragment(mMenuFragment); 
    } 


} 

nay là navigationview được coi là một mảnh ở đây để mã cho đoạn là ở đây:

public class MyMenuFragment extends MenuFragment{ 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View v = inflater.inflate(R.layout.fragment,container,false); 

     return setupReveal(v); 
    } 
} 

Vì vậy, đây là khá nhiều đó. Bạn có thể cảm ơn this person cho công việc tuyệt vời.

+0

Không khởi chạy ... hiển thị cho tôi lỗi này . java.lang.RuntimeException: Không thể bắt đầu hoạt động ComponentInfo {com.mxn.soul.flowingdrawer/com.mxn.soul.flowingdrawer.MainActivity}: java.lang.IllegalArgumentException: Mục tiêu không được rỗng. – Debasish

+0

Gây ra bởi: java.lang.IllegalArgumentException: Mục tiêu không được rỗng. tại com.squareup.picasso.RequestCreator.into (RequestCreator.java:607) tại com.squareup.picasso.RequestCreator.into (RequestCreator.java WEBC90) tại com.mxn.soul.flowingdrawer.MenuListFragment.setupHeader (MenuListFragment.java:58) tại com.mxn.soul.flowingdrawer.MenuListFragment.onCreateView (MenuListFragment.java:45) – Debasish

1

hoạt hình nhao

Bạn có thể mất sự giúp đỡ từ LINK

enter image description here enter image description here

Một ví dụ video này của thư viện này là về vấn đề này youtube video.

Các demo app thể được tìm thấy trên cửa hàng chơi.

+0

ohk cảm ơn bạn, bệnh thử này –

Các vấn đề liên quan