我正在测试材料设计,我正在使用扩展工具栏开发应用程序.我的应用程序非常简单:主要活动扩展ActionBarActivity,我的布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WeatherActivity"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
android:layout_height="128dp"
popupTheme="@style/ActionBarPopupThemeOverlay"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:text="@string/location_placeholder"
android:textAlignment="viewStart"
android:layout_gravity="start"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
现在我想将标题显示为当前位置.我注意到的第一件事是在我的Android模拟器(API 18)中,标题似乎不符合关于左边距底边距的材料指南,它出现在左侧并垂直输入工具栏内.我应该使用工具栏标题(toolbar.setTitle)还是其他什么?其次,如果我想创建更复杂的东西,如标题和简短的描述(如布局结构中的材料指南所示),我的布局应该是什么?谢谢您的支持!
我今晚正在尝试新闻主题,我想知道是否有人知道这个问题的解决方案.
当出现在自定义布局文件中时,它会显示在库存工具栏上,如下所示.
这是相对较小的,但我的强迫症眼睛是正确的,所以也许有人可以提供帮助.谢谢 :)

user-interface android android-layout material-design android-toolbar
我有自己的工具栏,我想为我的标题自定义字体,但我不能让它工作.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
SpannableString title = new SpannableString(getResources().getString(R.string.app_name));
title.setSpan(Typeface.createFromAsset(getAssets(), "KeepCalm-Medium.ttf"), 0, title.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
toolbar.setTitle(title);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)
我想我做得对,但它没有做任何事情.
请告诉我如何在imageview上添加textview,背景透明,如图所示.细节是我想在imageview上添加两个textview,一个textview是title,其余的是description.背景是透明的.请帮忙.
我正在尝试从我的应用中检索上传的图片:
intent = getIntent();
String id = intent.getStringExtra("id");
ParseQuery<ParseObject> query = ParseQuery.getQuery("Items");
query.getInBackground(id, new GetCallback<ParseObject>()
{
@Override
public void done(ParseObject object, ParseException e)
{
if (e == null)
{
setTitle(object.getString("name"));
textPlatform.setText(object.getString("platform"));
textPrice.setText(String.valueOf(object.getDouble("price")));
textDelivery.setText(String.valueOf(object.getDouble("delivery")));
textLocation.setText(object.getString("location"));
textCondition.setText(object.getString("condition"));
textSeller.setText(object.getString("seller"));
ParseFile applicantResume = (ParseFile) object.get("image");
applicantResume.getDataInBackground(new GetDataCallback()
{
public void done(byte[] data, ParseException e)
{
if (e == null)
{
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
imgItem.setImageBitmap(bmp);
}
else
{
e.printStackTrace();
}
}
});
} else
{
e.printStackTrace();
}
}
});
Run Code Online (Sandbox Code Playgroud)
我可以成功检索其他项目而不是文件(我知道存在并位于"图像"列下).
先谢谢你
你好:)我想改变我的应用程序,因此它将具有Material主题,所以..我安装了新的adt,在sdk管理器上更新所有,并做了这些东西:
我打开了一个新文件 - /res/values/styles.xml并在那里使用了这段代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- your app's theme inherits from the Material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- theme customizations -->
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest我使用了这段代码:
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="20" />
Run Code Online (Sandbox Code Playgroud)
在styles.xml我收到此错误:
"错误:检索项目的父项时出错:找不到与给定名称'android:Theme.Material'匹配的资源."
我需要改变什么?
我需要创建一个启动新应用程序的Android应用程序.新的应用程序需要在orig应用程序的不同进程上运行,需要有一个不同的包名,它需要是图形的(所以我认为排除服务,除非我弄错了,服务可以是图形化的)它需要安装与第一个相同的apk文件.它不会进入Android市场,所以我不关心市场问题.
我今天看到了一个完全符合我需要的应用程序,它在它的包名下运行了一个进程,并在"{orig.app.packgename}:remote"下打开了一个新进程.
任何人都可以告诉我这样的事情怎么办?
我正在尝试calendar从一个片段插入事件,但我一直收到错误,没有发现任何活动来处理Intent.
这是错误 -
android.content.ActivityNotFoundException:找不到处理Intent的Activity {act = android.intent.action.INSERT cat = [android.intent.category.APP_CALENDAR] typ = vnd.android.cursor.item/event(has extras)}
这是我的代码:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(Events.TITLE, "Phototherapy Treatment");
intent.putExtra(Events.EVENT_LOCATION, "");
intent.putExtra(Events.DESCRIPTION, "Phototherapy Treatment");
// Setting dates
Calendar calDate = Calendar.getInstance();
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis()+60*60*1000);
// Make it a full day event
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);
// Make it a recurring Event
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT="+Integer.valueOf(No.getText().toString())+";"
+"WKST=SU;BYDAY="+days);
// Making it private and shown as busy
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
意图过滤器
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.INSERT" …Run Code Online (Sandbox Code Playgroud) player.reset();
player.setDataSource(url);
// mPlayer.setDataSource(mFileName);
player.prepareAsync();
player.setOnPreparedListener(
new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
player.start();
}
}
);
Run Code Online (Sandbox Code Playgroud)
这是我的媒体播放器的位代码。我正在做应该正确执行的操作,以便正确设置媒体播放器的状态,但仍然出现错误start called in state 1,任何人都可以帮忙吗?非常感谢!
我正在开发一个为外部服务器发送数据(注册和图像)的Cordova应用程序,它已经正常工作但是如果用户在注册时没有互联网,应用程序正在后台运行等待互联网连接发送数据,怎么办?
所以我在Android Studio v 0.3.6上,我遇到了Google Play服务的问题.我已经在我的项目中使用Admob jar但我必须更新它,所以我尝试通过说明添加它们.我的项目编译正常但是当我尝试运行一个活动时,我收到以下错误:
Didn't find class "com.google.ads.AdView" on path: /data/app/com.mre. example-1. apk
Run Code Online (Sandbox Code Playgroud)
请参阅此处的完整错误输出.我的build.gradle的相关部分:
apply plugin: 'android'
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
//compile project(':libraries:google-play-services_lib')
//compile files('libs/google-play-services.jar')
...
}
android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的清单
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"ex">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data
android:name="com.google.android.gms.appstate.APP_ID"
android:value="@string/app_id" />
...
<activity
android:name="com.google.ads.AdActivity" …Run Code Online (Sandbox Code Playgroud) 尝试从 android-support-v7:21 库实现新的抽屉切换,但未显示。代码片段:
public class MainActivity extends ActionBarActivity {
private Toolbar mToolbar;
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initToolbar();
}
private void initToolbar() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
mDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
mToolbar,
R.string.drawer_open,
R.string.drawer_close
);
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
}
Run Code Online (Sandbox Code Playgroud) android android-support-library navigation-drawer android-toolbar