当我设计布局时,由于可维护性的主题,我集中了dimens.xml中的所有维度.我的问题是,这是否正确.什么是最好的做法?关于此的信息非常少,没什么.我知道在strings.xml上集中布局的所有字符串,colors.xml上的颜色是个好主意.但关于尺寸?
例如:
<TableLayout
android:id="@+id/history_detail_rows_submitted"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cebroker_history_detail_rows_border"
android:collapseColumns="*">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/history_detail_rows_margin_vertical"
android:background="@color/cebroker_history_detail_rows_background"
android:gravity="center"
android:paddingBottom="@dimen/history_detail_rows_padding_vertical"
android:paddingLeft="@dimen/history_detail_rows_padding_horizontal"
android:paddingRight="@dimen/history_detail_rows_padding_horizontal"
android:paddingTop="@dimen/history_detail_rows_padding_vertical">
<TextView
android:layout_width="match_parent"
android:drawableLeft="@mipmap/ic_history_detail_submitted_by"
android:drawablePadding="@dimen/history_detail_rows_textviews_padding_drawable"
android:gravity="left|center"
android:paddingRight="@dimen/history_detail_rows_textviews_padding"
android:text="@string/history_detail_textview_submitted_by"
android:textColor="@color/cebroker_history_detail_rows_textviews"
android:textSize="@dimen/history_detail_rows_textviews_text_size" />
Run Code Online (Sandbox Code Playgroud) 我已启用主页按钮返回上一个视图.简单地说,这样做:
getActionBar().setDisplayHomeAsUpEnabled(true);
我正在使用最新版本的com.android.support:appcompat-v7:21.0.2
.但是,当我使用下面的代码时,它不会抛出异常.
Espresso.onView(ViewMatchers.withId(android.R.id.home)).perform(ViewActions.click());
Espresso.onView(ViewMatchers.withId(R.id.home)).perform(ViewActions.click());
例外:
com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: is <2131296261> ...
我正在尝试将okHttp与Web服务连接,但使用不同的端口,例如10000.我的想法是在单元测试期间使用代理存根响应.但是,没有足够的文档来使用这个库.事实上,我的实施是:
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(TIMEOUT_MS, TimeUnit.MILLISECONDS);
Run Code Online (Sandbox Code Playgroud)
例如,对于其他库,例如loopj,此功能是可能的:
httpClient.setProxy("localhost", 10000);
Run Code Online (Sandbox Code Playgroud)
我正在使用这个版本: com.squareup.okhttp:okhttp:2.5.0