【发布时间】:2014-08-21 14:00:35
【问题描述】:
我正在尝试创建这个滑动面板,它会在我收到推送通知后自动显示,但我似乎无法正确处理。
我希望面板本身具有交互性,因此我希望它是一个不同的片段。
我的主要活动 xml 如下所示:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/panel"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"></FrameLayout>
</FrameLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/gradientbg"
android:choiceMode="singleChoice"
android:divider="#1c1c1c"
android:dividerHeight="1dp" />
<!-- android:background="#111" -->
</android.support.v4.widget.DrawerLayout>
只是为了尝试,我设置了这个简单的片段并尝试在点击Listener的textView上听:
public class Panel extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.panel, container, false);
view.bringToFront();
//view.animate().translationYBy(100f).setDuration(1300);
TextView text = (TextView) view.findViewById(R.id.textView);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
view.animate().translationYBy(-300f).setDuration(1300).start();
Toast.makeText(getActivity(), "fasf", Toast.LENGTH_SHORT).show();
}
});
return view;
}
}
不幸的是,textView 没有响应任何触摸事件。就像片段不在 z-index 上一样。
【问题讨论】:
-
先检查TextView是否设置为可点击?
-
是的,我已将其添加到 xml 中。还是不行
-
还加了onTouchListener,还是不行
标签: android slidingdrawer