小编The*_*Doc的帖子

优化和降低GPU Overdraw - Android

我在开发人员设置中打开了GPU Overdraw叠加层,发现我的应用程序没有经过优化,我不确定在哪里更改它以使其更好地工作.这是它的图像.

在此输入图像描述

红色部分都是ListView的一部分,因此我不知道如何在保持相同样式的同时优化它.这是每个ListView部分的layout.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_card"
android:orientation="horizontal"
android:padding="5dip" >

<ImageView
    android:id="@+id/list_image"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:src="@drawable/gta5thumb"
    android:padding="3dip"
    android:background="@drawable/image_bg"
    android:layout_centerVertical="true"/>





<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@id/list_image"
    android:layout_toRightOf="@id/list_image"
    android:text="Grand Theft Auto 5"
    android:textColor="#040404"
    android:textSize="18sp"

    android:layout_marginLeft="4dp"
    android:textStyle="bold"/>

<TextView
    android:id="@+id/date1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/title"
    android:textColor="#343434"
    android:textSize="14sp"
    android:layout_marginTop="1dip"
    android:layout_toRightOf="@id/list_image"
    android:layout_marginLeft="4dp"
    android:text="17th September 2013" />
<TextView
    android:id="@+id/date2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/date1"
    android:textColor="#343434"
    android:textSize="14sp"
    android:layout_marginTop="1dip"
    android:visibility="visible"
    android:layout_marginLeft="4dp"
    android:layout_toRightOf="@id/list_image"
    android:text="17th September 2013" />
<TextView
    android:id="@+id/date3"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#343434"
    android:textSize="14sp"
    android:layout_marginLeft="4dp"
    android:text="17th September 2013"
    android:layout_below="@+id/date2"
    android:layout_toRightOf="@+id/list_image"/>

<TextView
    android:id="@+id/platforms"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@id/title" …
Run Code Online (Sandbox Code Playgroud)

optimization android listview

7
推荐指数
1
解决办法
4165
查看次数

带有ListView的Google Card Style 9-Patch - Android

我正在尝试使用从play store apk中提取的card_background 9-patch,我无法正确地将9-Patch放置.这是我的模拟器运行此问题的图像.我正在尝试制作现在常用的典型卡片视图,但这只是我无法解决的问题之一.

在此输入图像描述

我的9-Patch card_background: 在此输入图像描述

我也非常确定9-Patch设置不正确,因为根据/ sdk/tools中的9-Patch工具,我使用的所有两个区域都是坏补丁但我不知道这意味着什么所以我希望一个你可以帮忙解决这个问题.

android listview nine-patch

1
推荐指数
1
解决办法
4725
查看次数

删除ListView分隔符颜色,使其透明或设置背景,而不重绘像素. - Android

我在这里有一个非常简单的问题.你可以删除ListView分隔符颜色,因为它只是保持透明,因为默认的应用程序背景有一个轻微的渐变,如果你将分隔符设置为背景的某种颜色,因为它匹配某些地方而不是其他.

我的另一个问题是,如果这是不可能的,那就是可以为应用程序设置自定义背景,而不会让应用程序重绘像素,从而增加额外的GPU Overdraw.如果您使用android:background ="#e6e6e6"使应用程序设置背景的正常方式,那么像素会在其上添加另一层,从而导致性能降低.这就是为什么我会为风格设置主色,尽管我有点确定这是不可能的.

transparency android listview background divider

1
推荐指数
1
解决办法
2422
查看次数

如果未连接,如何检查Internet连接并生成对话框

我的应用程序主要是基于互联网的,当设备没有上网时,它只是崩溃,因为它试图下载文件,但没有成功.我也刚刚在输入时意识到如果它需要的数据离线它也会崩溃.我已经尝试阅读文档并尝试将其添加到我的应用程序,但似乎我需要的东西与我一直在阅读的东西不同.

  • 最好在活动上添加"无互联网连接"对话框,而不是通过吐司.
  • 将"数据不可用"对话框添加到可能在吐司中的片段

我使用我的MainActivity来加载片段,所以我怀疑我可以在其中放置某种代码来显示片段使用区域的对话框.无论哪种方式,我将添加我的MainActivity和我的互联网加载片段.

MainActivity.class:

public class MainActivity extends SherlockFragmentActivity {

    private ViewPager mViewPager;
    private TabSwipe mTabSwipe;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new FirstLaunchEULA(this).show();



        mViewPager = new ViewPager(this);
        mViewPager.setId(R.id.pager);
        mViewPager.setOffscreenPageLimit(2);
        setContentView(mViewPager);

        final ActionBar bar = getSupportActionBar();
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mTabSwipe = new TabSwipe(this, mViewPager);
        mTabSwipe.addTab(bar.newTab().setText("Games"), A_Internet_Service.class, null);
        mTabSwipe.addTab(bar.newTab().setText("Movies"), Test_Fragment.class, null);
        mTabSwipe.addTab(bar.newTab().setText("Tech"), Purchase_Fragment.class, null);


    }

}
Run Code Online (Sandbox Code Playgroud)

A_Internet_Service.class:

public class A_Fragment_Service extends Fragment {

    // All static variables
    static final String URL = "this.is.a.url";
    // XML node keys
    static final String KEY_DATA …
Run Code Online (Sandbox Code Playgroud)

android dialog

1
推荐指数
1
解决办法
8195
查看次数