小编nat*_*241的帖子

如何删除Android工具栏的左边距?

我正在尝试使用工具栏来完成我的项目.这是我正在使用的代码:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_alignParentTop="true"
    android:background="?attr/colorPrimary"
    android:contentInsetLeft="0dp"
    android:elevation="@dimen/margin_padding_8dp"
    android:contentInsetStart="0dp">

    <RelativeLayout
        android:id="@+id/rlToolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tvTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:paddingRight="@dimen/margin_padding_16dp"
            android:text="AppBar"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@color/white"
            android:textSize="@dimen/text_size_20sp" />

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)


工具栏

我想删除左侧空白,在这里我设置的android:contentInsetLeft ="0dp"机器人:contentInsetStart ="0dp",但它不是 working..Please帮帮我吧!

android toolbar android-layout android-design-library

29
推荐指数
4
解决办法
2万
查看次数

如何使用TabLayout Android Design创建带图标的应用栏?

我正在尝试在Android设计库中使用新的TabLayout来创建带有图标的应用栏.

public void setupTabLayout(TabLayout tabLayout) {
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
    tabLayout.setupWithViewPager(mViewpager);
    tabLayout.getTabAt(0).setIcon(R.drawable.ic_tabbar_library);
    tabLayout.getTabAt(1).setIcon(R.drawable.ic_tabbar_recents);
    tabLayout.getTabAt(2).setIcon(R.drawable.ic_tabbar_favorites);
    tabLayout.getTabAt(3).setIcon(R.drawable.ic_tabbar_notifications);
    tabLayout.getTabAt(4).setIcon(R.drawable.ic_tabbar_settings);
}
Run Code Online (Sandbox Code Playgroud)

结果:

带有图标的应用栏

请帮我创建类似的app栏:

带有图标的应用栏

对不起,我的英语不好.谢谢提前!

android-tabhost android-tabs android-design-library

19
推荐指数
1
解决办法
3万
查看次数

如何从surfaceview创建和保存屏幕截图?

我有一个应用程序,我希望能够捕获屏幕截图

这是我的代码:

public class Screenshot {

    private final View view;

    /** Create snapshots based on the view and its children. */
    public Screenshot(View root) {
            this.view = root;
    }

    /** Create snapshot handler that captures the root of the whole activity. */
    public Screenshot(Activity activity) {
            final View contentView = activity.findViewById(android.R.id.content);
            this.view = contentView.getRootView();
    }

    /** Take a snapshot of the view. */
    public Bitmap snap() {
            Bitmap bitmap = Bitmap.createBitmap(this.view.getWidth(), this.view.getHeight(), Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            view.draw(canvas);
            return …
Run Code Online (Sandbox Code Playgroud)

android screenshot surfaceview

9
推荐指数
1
解决办法
2万
查看次数