- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 Android 应用程序,其中有一个已插入 color.xml 的颜色列表。这些颜色适用于从 Activity 中创建的注释。因此,用例是用户输入标签、文本并从 color.xml 的可用颜色中选择颜色。
请注意,我不是在寻找颜色选择器,因为颜色已经选择,用户只能从这些中进行选择
因此,我想在小框中向用户显示颜色列表作为预览(为此留有空间),单击后,将出现一个下拉菜单,显示插入 color.xml 中的名称以及相关的预览。
我不知道实现此任务需要哪种类型的容器或需要什么。我将发布可用的代码和颜色。请指导我应该如何进行
color.xml:仅用户可以拥有的颜色:
<color name="noteAqua">#1abc9c</color>
<color name="noteBlue">#3498db</color>
<color name="noteDarkBlue">#34495e</color>
<color name="noteDeepBlue">#0071c1</color>
<color name="noteDeepRed">#c00000</color>
<color name="noteGreen">#2ecc71</color>
<color name="noteGrey">#95a5a6</color>
<color name="noteOrange">#e67e22</color>
<color name="notePink">#ff56bb</color>
<color name="notePurple">#9b59b6</color>
<color name="noteRed">#e74c3c</color>
<color name="noteYellow">#f1c40f</color>
create_note.xml :如果你们运行了 android IDE,您可以复制粘贴下面的 XML,您将能够注意到,我在右上角留下了一个空白,我想在其中插入以下列表:颜色。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<EditText
android:layout_width="315dp"
android:layout_height="wrap_content"
android:id="@+id/noteTagAddText"
android:gravity="center_vertical|center_horizontal" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/noteTextAddText"
android:layout_gravity="center_horizontal"
android:layout_weight="0.97"
android:gravity="top" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="191dp"
android:layout_height="wrap_content"
android:text="@string/saveNoteString"
android:id="@+id/createNoteButton"
android:layout_gravity="right" />
<Button
android:layout_width="191dp"
android:layout_height="wrap_content"
android:text="@string/cancelSaveString"
android:id="@+id/cancelCreateButton" />
</LinearLayout>
</LinearLayout>
CreateNoteActivity 类:
public class CreateNoteActivity extends Activity {
EditText noteTag, noteText;
Button saveButton, cancelButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_note);
Bundle extras = getIntent().getExtras();
if (extras != null) {
groupAccountId = extras.getLong("groupid");
canvasId = extras.getInt("canvasid");
sectionid = extras.getInt("sectionid");
}
noteTag = (EditText) findViewById(R.id.noteTagEdit);
// noteTag.setText(restNote.getMnotetag());
noteText = (EditText) findViewById(R.id.noteTextEdit);
// noteText.setText(Html.fromHtml(restNote.getMnotetext()));
noteText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s){
// restNote.setMnotetext(s.toString());
}
});
noteTag.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
// restNote.setMnotetag(s.toString());
}
});
saveButton = (Button) findViewById(R.id.saveNoteButton);
cancelButton = (Button) findViewById(R.id.cancelEditButton);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RestNote saveNote = new RestNote();
// saveNote.setMnotecolor(restNote.getMnotecolor());
saveNote.setMnotetag(noteTag.getText().toString());
saveNote.setMnotetext(noteText.getText().toString());
// saveRestNoteOnServer(restNote);
Intent intent = new Intent(getApplicationContext(),GroupSectionActivity.class);
intent.putExtra("groupid", groupAccountId);
intent.putExtra("canvasid", canvasId);
intent.putExtra("sectionid",sectionid);
startActivity(intent);
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),GroupSectionActivity.class);
intent.putExtra("groupid", groupAccountId);
intent.putExtra("canvasid", canvasId);
intent.putExtra("sectionid",sectionid);
startActivity(intent);
}
});
}
}
任何帮助都会很好。多谢。 :-)
编辑
如下图所示,当用户单击该图像时,我会在 Activity 中获取颜色 ID。
最佳答案
只需使用 ImageView 并将背景属性设置为您的颜色,就像这样;
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/yourcolour"/>
然后你可以在这个 ImageView 上设置一个点击监听器,并在点击它后做任何你喜欢的事情。
yourImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// do something
}
});
关于java - Android : Show a list of color previews and pass associated id from color. xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33127375/
假设我有一个颜色数组(具有整个色谱,从红色到红色。)。较短的版本如下所示: public Color[] ColorArray = new Color[360] { Color.FromArgb(25
当我通过 http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.gamefriction.com%2FCoded&prof
我需要帮助来解决验证 CSS。在这里,我在 W3 验证中遇到了 20 个相同的错误。我不明白。如果您能解决此问题,我将不胜感激。 错误:两种上下文中 color 和 background-color
我正在尝试覆盖 bootstrap4 样式。 我没有使用 Sass 的经验,但这看起来像是 bootstrap SCSS 文件中的错误。 我的自定义文件是: /* custom.scss */
我是 sass 的新手,我写了一些 sass 代码,但它没有编译。 $classes : primary secondary success warning danger; $colors
我想制作一个散点图,其中每个点都有一个球体。点及其球体都根据某些列值着色。 一个显示我想要的最小示例: library(ggplot2) library(vcd) # only needed for
我正在尝试添加一个选项来更改网站颜色。所以,我有一个工作正常的色域,但问题是当鼠标悬停时我需要将颜色更改为深 10%。函数 darken 表示第一个参数必须是颜色。 Error: argument `
我正在尝试从下拉菜单中更改主题颜色,但出现此错误:“预期类型为'List>'的值,但类型为之一 'MappedListIterable>' Color selected ; MaterialApp(
有没有办法将 Inno Setup 底部面板的背景颜色更改为白色? 谢谢你的帮助! 最佳答案 您描述的底部面板实际上是向导表单的区域,因此您只需设置 Color WizardForm 的属性(prop
sublime text包Color Highlighter看起来很有用。但是,它的行为似乎并不像文档中描述的那样。 根据文档: Usage : Just click or move the curs
我有一个由 Excel 2007 创建的文档: ... 在 xl/styles.xml 的字体定义中包含以下颜色: 我从ECMA标准了解到这个颜色索引指的是收藏于 xl/styles.xml如果有
简单问题: (如何)是否可以设置 的值在 Chrome 中选择此类输入时,要在颜色选择器中清空吗? 编辑:我想将输入的值更改为 "" 最佳答案 我认为它不能设置为透明,但您可以使用value="#c
我正在尝试截屏,检查屏幕截图中的某种颜色,如果找到该颜色,则单击它。 我遇到的问题是颜色的 RGB 值必须准确。 我想知道是否可以将图像转换为颜色很少的图像。 抱歉打扰了。我没有受过适当的训练。我现在
有谁知道为什么 CSS 为文本提供了 color,但没有 font-color 或 text-color? 看起来很反直觉,有点像text-decoration: underline 而不是font-
我想弄清楚为什么 mix-blend-mode: color; css 选择器和值会影响除白色以外的所有颜色,而不是影响除白色和黑色以外的所有颜色。有人可以向我解释为什么会这样吗? 最佳答案 来自 t
我正在尝试创建 Angular 2 主题,我按照网站上提到的教程进行操作。这是我的主题文件。 @import '~@angular/material/theming'; @include mat-co
我正在尝试更改 ProgressBar 中栏的颜色 pBar.setStyle("-fx-accent: green"); 但我遇到了一个问题:这似乎不适合我! (或者我只是不明白一些事情) 这是代码
给定最大迭代次数 = 1000 给我一些关于如何着色(红色、绿色、蓝色)的想法。我现在能想到的只有蹩脚的 2 种颜色渐变:( 真的有可能想出像这样美丽的东西吗? 最佳答案 该死的,他们不会让我一个新手
要将 url 参数解码为颜色,我使用此 HttpMessageConverter: public class ColorHttpMessageConverter implements HttpMess
我创建了一个显示色谱的自定义控件。我正在覆盖 OnRender() 方法以使用颜色绘制控件。由于某种原因,“计算”的颜色(R G B 值)具有一定的透明度,即使我将 Alpha 值 (A) 设置为最大
我是一名优秀的程序员,十分优秀!