我正在尝试导入现有的android项目,项目xml图形/设计布局未加载.我做了一个新的测试项目和xml图形布局工作正常,我不知道是什么问题.我刚刚安装了新的android sdk r14,我不知道是什么问题,有谁可以在这方面帮助我?
您可以在附加的快照中看到它.
谢谢
!!
我有一个Shape定义xml.现在我需要solid color从代码中更改一个,请问如何建议?
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#000000"/>
<corners
android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud) 因此,我将使我的应用程序使用Multilingual并为不同的语言制作不同的String.xml.我也在改变我的文本,例如
String message = "Calling " + name;
Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, message, duration);
toast.show();
Run Code Online (Sandbox Code Playgroud)
至
String message = toastCalling + name;
Run Code Online (Sandbox Code Playgroud)
(来自strings.xml)
<string name="toastCalling">Calling</string>
Run Code Online (Sandbox Code Playgroud)
我遇到一个问题,它显然是一个INT,要么无法解析,要么将toastCalling(Calling)的值更改为"278172"(随机数)
有没有办法获得R.String.toastCalling(Calling)的ACTUAL值
我试过了:
String whatever = getResources().getString(R.string.toastCalling);
Run Code Online (Sandbox Code Playgroud)
但我不认为这是实际的.
提前致谢!
我想在视图底部有一个不同小部件的“工具栏” ...每个小部件都由ImageView代表图标和TextView描述的组成。这是XML代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linear_layout_shelves"
android:background="@drawable/final_shelves"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="70dp"
android:layout_marginRight="65dp"
android:layout_marginTop="@dimen/first_shelf_margin_top"
android:orientation="horizontal" >
<ImageView
android:id="@+id/image_11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image1"
android:clickable="true"/>
<ImageView
android:id="@+id/image_12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image2"
android:clickable="true" />
<ImageView
android:id="@+id/image_13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image3"
android:clickable="true" />
</LinearLayout>
<!-- "Tools" : Cancel, delete, details -->
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
<!-- Cancel Widget -->
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/delete_widget"
android:layout_weight="1"
android:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel_icon"
android:src="@drawable/cancel_128"
android:clickable="true" …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,但它看起来非常简单,因为它只有活动上的文本.我想知道如何在UI中添加一些元素,具体来说,我是如何添加一个圆形的形状,它将被包裹在TextView中.这是我想做的事情的一个例子......

所以我的问题是,如何将形状添加到将围绕TextViews的Android布局中?我试过研究这个话题,但运气不好.所以任何教会我如何做到这一点的资源也会有所帮助.此外,如果您知道如何添加此页面的其他元素,例如左侧24米以下的线条和指向图标的蓝色指针,那么这也会有所帮助.我想学习关于设计一个令用户满意的漂亮界面的一切.谢谢你的帮助.
android nine-patch android-layout android-xml android-activity
我一直想知道这个问题.
构建XML Android布局时,我们可以TextView使用RGB十六进制代码或color.xml文件中的颜色值来定义文本颜色.
android:textColor="#FFFFFF"
Run Code Online (Sandbox Code Playgroud)
要么
android:textColor="@android:color/white"
Run Code Online (Sandbox Code Playgroud)
这只是一个可读性问题,在绘制布局时根本没有任何影响,或者它是否会对性能产生影响?
我有2个LinearLayouts的Weight1,有第一个布局,如果我添加任何东西它占据全宽而不是屏幕的一半,如何避免这个
<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"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:weightSum="2"
tools:context="com.example.testapp1.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/Aqua"
android:orientation="vertical"
android:weightSum="2" >
<LinearLayout
android:id="@+id/subview_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Green"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/insideLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Yellow" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/Aqua"
android:orientation="vertical" >
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/DarkGray" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/BlueViolet"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>Run Code Online (Sandbox Code Playgroud)
在添加视图标记时,它占据全宽而不是weight1中指定的一半,我正在制作什么问题
我有这个dialog fragmentt,我有两个问题.
1.如何使宽度与父母相匹配(最干净,最好的解决方案).
- 在
dialog fragment我有一个editText.当对话框片段打开时,如何让它弹出软键盘?
希望你们能帮忙!
这是我的对话框片段java代码:
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
rootView = inflater.inflate(R.layout.activity_13g_add_comment, container, false);//The container is the rootView.
myCognito = new MyCognito(getActivity().getApplicationContext(),getActivity().getBaseContext());
cardClient = myCognito.getCardClient();
bindActivity();
return rootView;
}
private void bindActivity()
{
doneButton = (ImageButton) rootView.findViewById(R.id.add_comment_doneButton);
doneButton.setVisibility(View.GONE);
imageView = (ImageView) rootView.findViewById(R.id.add_comment_IV);
RemoveGlideCacheAsyncTask removeGlideCacheAsyncTask = new RemoveGlideCacheAsyncTask(getActivity().getBaseContext(),Global_Class.getInstance().getValue().user.getUsername());
removeGlideCacheAsyncTask.execute();
editText = (EditText) rootView.findViewById(R.id.add_comment_ET);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) …Run Code Online (Sandbox Code Playgroud) xml android android-layout android-xml android-dialogfragment
我有一个我在网站上看到的按钮,我想在xml中重新创建它.但是,我无法确定正确的尺寸.下面是我到目前为止的代码,但它与形状不完全匹配.希望有人可以帮忙!
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/white"></solid>
<corners
android:radius="600dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<stroke
android:width="3px" android:color="@color/salmon_main"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我正在努力制作一个很酷的布局,如下所示:
为此,我正在使用Github的 Android Parallax库。该库从xml本身创建所有视图(如图所示)。但是我想创建自己的recyclerview,创建adpater,模型类并使用cardview显示它们。
我尝试使用cardview和recyclerview。
问题:
当我将RecyclerView的高度设置为match_parent(android:layout_height =“ match_parent”)时,它给出如下的UI:
仅显示第一张卡片视图,仅显示一半。其他卡片视图以某种方式重叠。
但是,当我使用固定高度(例如1000dp,2000dp)给出其高度时,它会按预期显示UI(如第一个图所示)。我认为将其高度固定是一个不好的解决方案,因为数据项可能会有所不同。
我不明白我的代码有什么问题。请为此提出一些解决方案。
以下是我对代码的不同看法。
activity_main.xml
<com.github.florent37.parallax.ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/background"
android:tag="parallax=0.3" />
<TextView
style="@style/MyTitle"
android:layout_width="match_parent"
android:layout_height="160dp"
android:gravity="center"
android:tag="parallax=0.5"
android:text="My awesome title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="150dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</LinearLayout>
</FrameLayout>
</com.github.florent37.parallax.ScrollView>
Run Code Online (Sandbox Code Playgroud)
card_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView …Run Code Online (Sandbox Code Playgroud)