我有两个不同的活动,我想在另一个活动中同时显示它们.有没有办法做到这一点?
提前致谢!
android android-layout android-fragments android-view android-activity
我正在使用Eclipse开发本机Android应用程序,我在Android Manifest上添加了以下权限
<uses-permission android:name="android.permission.CALL_PHONE" />
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试在我的设备上安装Android应用程序时,我收到以下消息:
直接拨打电话号码可能会花费你的钱
我可以做些什么来隐藏这条消息,因为我认为这对用户不友好吗?也许我需要使用另一个许可,这是一个没有许可的更接近的许可?
我在我的适配器上使用了以下代码:
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(PhoneCall));
v.getContext().startActivity(callIntent); }
});
Run Code Online (Sandbox Code Playgroud) 这很愚蠢,但是如何在Android上放置背景rgb?
我正在尝试放置RGB颜色的背景,但找不到方法。
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background= ?
android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)
我已经这样做了,但是没有用
Color.rgb(200,0,0)
Run Code Online (Sandbox Code Playgroud) 这是我的第一个Android应用程序.我正在尝试做一些应该相对简单的事情,但我似乎无法让它发挥作用.
AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project1.project1">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/icon_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/icon_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
login_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/loginSignup1Background"
tools:context=".LoginActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp"
android:text="@string/login_title"
android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:contentDescription="Login Icon" …Run Code Online (Sandbox Code Playgroud) 无论屏幕尺寸如何,我都需要在每个按钮之间从上到下保持相等的垂直距离.这是相同的代码:
没有要使用的静态值.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:weightSum="3"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)我想将 my_fragment1 实现到 tab1 片段中,如何将片段组合成片段。
表1
public class Tab1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.tab1, container, false);
list_fragment fm = (list_fragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.My_Container_1_ID);
}
Run Code Online (Sandbox Code Playgroud)
表1.xml
<FrameLayout
android:id="@+id/My_Container_1_ID"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/button"
android:layout_toStartOf="@+id/button">
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) 谁能告诉我如何设计一个Material设计cardview中Android Studio包括适配器和布局文件?如果有人可以也请分享源代码。
我正在创建一个ProgressBar放置在LinearLayout的垂直中心(其他布局不起作用;我需要使用LinearLayout).这是一些代码:
LinearLayout linearLayout = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
linearLayout.setLayoutParams(layoutParams);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setGravity(Gravity.CENTER);
//add progressbar
ProgressBar progressBar = new ProgressBar(context);
progressBar.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.addView(progressBar);
Run Code Online (Sandbox Code Playgroud)
我有一个ContainerView,它将保存上面创建的LinearLayout.像这样的东西:
public class ContainerView extends ScrollView {
public ContainerView(Context context) {
super(context);
initView(context);
}
private void initView(Context context){
addView(linearLayout); //which is created in the snippet above
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用LinearLayout扩展ContainerView,一切正常.
如果我使用ScrollView扩展ContainerView,则ProgressBar水平居中但不垂直居中.
这种双重行为背后的原因是什么?我的目标是在下载一些数据时显示ProgressBar; 下载数据后,我需要在LinearLayout中显示它.
(注意:使用ScrollView的原因是下载的数据可能太大而不适合小屏幕.这可能看起来像ListView的用例,但还有一些其他原因阻止我使用ListView.)
android scrollview android-layout layout-gravity android-gravity