Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 偏移垂直居中的RelativeLayout子对象的垂直位置_Android - Fatal编程技术网

Android 偏移垂直居中的RelativeLayout子对象的垂直位置

Android 偏移垂直居中的RelativeLayout子对象的垂直位置,android,Android,我有一个可视寻呼机: <android.support.v4.view.ViewPager android:id="@+id/ft_graph_pager" android:layout_width="match_parent" android:layout_height="@dimen/bar_graph_pager_height" android:layout_marginLeft="8dp" android:layout_marginRight="8d

我有一个可视寻呼机:

<android.support.v4.view.ViewPager android:id="@+id/ft_graph_pager"
    android:layout_width="match_parent"
    android:layout_height="@dimen/bar_graph_pager_height"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@id/ft_rsvp_graph_indicator"/>

有什么想法吗?

好吧,我不知道如何通过XML实现这一点,因此如果有人能够做到这一点,请继续发布,我会将其作为正式答案

不过,我还是能够想出一个Java解决方案。当我在活动中声明我的ViewPager时,我刚刚添加了以下内容:

Display display = mActivity.getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
ViewHelper.setTranslationY(mGraphPager, 5 * metrics.density);
5作为dp,我最终将其向下移动。ViewHelper是库的一部分,它帮助模拟API 11中添加的View类中的方法+

Display display = mActivity.getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
ViewHelper.setTranslationY(mGraphPager, 5 * metrics.density);