这是我的布局:
...
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.6"
>
<android.support.constraint.ConstraintLayout
android:id="@+id/myclayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintTop_toTopOf="parent"
></android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
...
Run Code Online (Sandbox Code Playgroud)
如何以编程方式设置constraintHeight_percent?
我尝试使用 ConstraintSet 但没有用
ConstraintSet set = new ConstraintSet();
set.constrainPercentHeight(R.id.myclayout, (float) 0.4);
set.applyTo(((ConstraintLayout) vw.findViewById(R.id.myclayout)));
Run Code Online (Sandbox Code Playgroud) 我能够发送带有单个附件的电子邮件,但我找不到在单个邮件中发送多个附件的任何内容
try {
SendGrid sendgrid = new SendGrid(SENDGRID_USERNAME, SENDGRID_PASSWORD);
SendGrid.Email email = new SendGrid.Email();
// Get values from edit text to compose email
// TODO: Validate edit texts
email.addTo(mTo);
email.setFrom(mFrom);
email.setSubject(mSubject);
email.setText(mText);
// Attach image
if (mUri != null) {
email.addAttachment(mAttachmentName, mAppContext.getContentResolver().openInputStream(mUri));
}
// Send email, execute http request
SendGrid.Response response = sendgrid.send(email);
mMsgResponse = response.getMessage();
Log.d("SendAppExample", mMsgResponse);
} catch (SendGridException | IOException e) {
Log.e("SendAppExample", e.toString());
}
return null;
}
Run Code Online (Sandbox Code Playgroud) 我正在处理需要在后台服务中连续获取位置更新的应用程序.我使用了它正在使用的后台粘性服务.但是,即使我已经添加了启动广播并在那里启动了服务,服务也不会在启动完成后启动.服务开始并立即被杀死.
此外,这不适用于奥利奥.应用程序关闭几分钟后服务停止,直到应用程序重新启动后才会重新启动.
我已经浏览了很多链接,博客建议使用AlarmManager/JobScheduler/JobIntentService,但没有得到满意的解决方案.因此,请建议即使在启动后也可用于在后台持续获取位置的工作策略/解决方案,并且应该在Oreo上工作.
所以,我想制作一个在后台带有视频的应用程序,每当应用程序启动时,视频就会播放,但一个问题是它只播放一次并且从不循环。这是我的代码
@Override
protected void onResume() {
super.onResume();
VideoView video = (VideoView) findViewById(R.id.videoview1);
Uri videoPath = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.great);
video.setVideoURI(videoPath);
video.start();
}
Run Code Online (Sandbox Code Playgroud) 当我使用setOnNavigationItemSelectedListener冻结BottomNavigationView波纹效果时,如下面的屏幕截图所示。并且效果状态一直保持这样。
我不明白为什么?
我在用着com.android.support:design:27.1.1
binding = DataBindingUtil
.setContentView(this, R.layout.activity_main)
bottomBar = binding?.bottomBarNavigation as BottomNavigationView
bottomBar?.setOnNavigationItemSelectedListener {
when (it.itemId) {
TabBarObject.TAB_MESSENGER -> replaceFragment(
MessengerFragment(),
TabBarObject.TAB_MESSENGER.tabName
)
...
...
}
}
private fun getTabInfo(menuItemId: Int): TabBarObject {
return when (menuItemId) {
R.id.tab_messenger -> TabBarObject.TAB_MESSENGER
...
...
else -> throw IllegalArgumentException("UNKNOWN TAB BAR TYPE")
}
}
private fun replaceFragment(fragment: Fragment, tag: String): Boolean {
val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.frame_layout, fragment, tag)
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
ft.commitAllowingStateLoss()
return true
}
Run Code Online (Sandbox Code Playgroud)
活动主文件
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 你好我有TextView的问题.这是我的代码
final TextView username = (TextView) _v.findViewById(R.id.username);
final LinearLayout linear7 = (LinearLayout) _v.findViewById(R.id.linear7);
final TextView date = (TextView) _v.findViewById(R.id.date);
final TextView msg = (TextView) _v.findViewById(R.id.msg);
final TextView username2 = (TextView) _v.findViewById(R.id.username);
final LinearLayout linear72 = (LinearLayout) _v.findViewById(R.id.linear7);
final TextView date2 = (TextView) _v.findViewById(R.id.date);
final TextView msg2 = (TextView) _v.findViewById(R.id.msg);
final LinearLayout linear999 = (LinearLayout) _v.findViewById(R.id.linear999);
final LinearLayout linear9992 = (LinearLayout) _v.findViewById(R.id.linear9992);
username.setText(map1.get((int)_position).get("name").toString());
msg.setText(map1.get((int)_position).get("msg").toString());
date.setText(map1.get((int)_position).get("date").toString());
username2.setText(username.getText().toString());
msg2.setText(msg.getText().toString());
date2.setText(date.getText().toString());
Run Code Online (Sandbox Code Playgroud)
如您所见,username2应与用户名具有相同的文本.但是,它只有我在设计师中为它提供的文本.请帮忙.