如何在按下时设置MenuItems工具栏的样式(How to styling MenuItems Toolbar when pressed)
在KitKat中,我在受支持的库工具栏中有一个样式化的选项菜单,定义如下
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:background="?attr/colorPrimary" app:theme="@style/ToolbarText" app:popupTheme="@style/optionMenu" />
optionMenu样式的位置
<style name="optionMenu"> <item name="android:textColor">@color/menu_text</item> <item name="android:background">@color/menu_background</item> </style>
它按预期工作,但是当我按下MenuItems时,它不会在所有可用空间中采用“默认灰色”颜色,而是仅在菜单元素周围的边缘上,其背景保持颜色,如样式中所定义。 我的目标不是改变压缩事件的风格,我只希望文本背后的背景在按下时看起来像整个矩形按钮
我哪里错了?
In KitKat, I have a styled options menu in a supported library toolbar defined as following
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:background="?attr/colorPrimary" app:theme="@style/ToolbarText" app:popupTheme="@style/optionMenu" />
where the optionMenu style is
<style name="optionMenu"> <item name="android:textColor">@color/menu_text</item> <item name="android:background">@color/menu_background</item> </style>
It works as expected, but when i press a MenuItems, it doesn't take the "default grey" color in all available space, but only on the edges around the menu element whose background remains colored as defined in the style. My goal is not to change the style onpressed event, i wish only that the background behind the text looks like the whole rectangular button when pressed
Where am I wrong?
原文:https://stackoverflow.com/questions/26990251
最满意答案
我认为再多一点研究,你显示的决定或减少的条件可以被简化很多。 但是,下面是一个实现您的条件的SQL语句:
SELECT SUM( IF(Upvote='true' AND Downvote='false',1, IF(upvote='false' AND Downvote='true',-1, IF(Upvote='false' AND Downvote='false',-1, IF(Downvote='false',1, IF(Downvote='true' AND (Upvote='0' OR Upvote=false),-1,0) ) ) ) )) as `votes` FROM Ratings WHERE TopicD = :current
如果只有'真正'的价值观,这可能会诀窍:
SELECT SUM(IF(Upvote='true',1,0)) - SUM(IF(Downvote='true',1,0)) as `votes` FROM Ratings WHERE TopicD = :current
I think with a little more study, the conditions you show to decide up or down count could be simplified quite a bit. But, here's a SQL statement that implements your conditions:
SELECT SUM( IF(Upvote='true' AND Downvote='false',1, IF(upvote='false' AND Downvote='true',-1, IF(Upvote='false' AND Downvote='false',-1, IF(Downvote='false',1, IF(Downvote='true' AND (Upvote='0' OR Upvote=false),-1,0) ) ) ) )) as `votes` FROM Ratings WHERE TopicD = :current
If only 'true' values count, this might do the trick:
SELECT SUM(IF(Upvote='true',1,0)) - SUM(IF(Downvote='true',1,0)) as `votes` FROM Ratings WHERE TopicD = :current
相关问答
更多-
SELECT a.asset_id, f.filename, coalesce(SUM(v.vote = '1'), 0) as upvote, coalesce(SUM(v.vote = '-1'), 0) as downvote FROM asset a JOIN asset_files f ON a.asset_id = f.asset_id LEFT JOIN vote v ON a.asset_id = v.asset_id GROUP BY a.asset_id D ...
-
var articles = GetArticleList(); var topArticles = articles.OrderByDescending(a => a.Votes.Count).Take(5); 您需要降序条款,以便您首先获得最高票数的文章。 var articles = GetArticleList(); var topArticles = articles.OrderByDescending(a => a.Votes.Count).Take(5); You need the des ...
-
[编辑:]我增加了值(1052,10,3,1290839091,1)以更好地解决问题,并且必须将“item_id”添加到提取最新投票的子查询中。 好极了! 最后一个stackoverflow问题,我可以真正回答! 我一直在浏览一周,寻找短暂的甜蜜和我的胡同。 感谢一个有趣的SQL问题! 首先,你需要提取最新的投票。 (voter_id,item_id,vote_date)的组合更适合这种工作方式! SELECT voter_id, item_id, MAX(vote_date) AS vote_date ...
-
什么使得StackOverflow中的投票按钮位于不同的行上?(What makes the vote buttons in StackOverflow be on different lines?)[2023-04-04]
他们正在对所有三个项目应用display:block 。 这很重要,因为默认情况下, img和span元素是内联的,不同的是p和div标签默认是块元素。 display:block元素display:block默认情况下, display:block将从左到右占据整个空间,并保持自己的行,并将其他元素推到下一行。 即使应用了限制其大小的宽度,它们仍然保留在自己的行上,除非将position更改为绝对或float元素。 They are applying display:block to all three ... -
您可以使用以下查询: SELECT pc.id, COUNT(*) FROM Poll_categories AS pc CROSS JOIN ( SELECT DISTINCT voters_id FROM Poll_votes) AS voters LEFT JOIN ( SELECT voters_id, poll_category_id FROM Poll_votes AS pv LEFT JOIN Poll_items AS pi ON pv.poll_item_id = ...
-
我认为再多一点研究,你显示的决定或减少的条件可以被简化很多。 但是,下面是一个实现您的条件的SQL语句: SELECT SUM( IF(Upvote='true' AND Downvote='false',1, IF(upvote='false' AND Downvote='true',-1, IF(Upvote='false' AND Downvote='false',-1, IF(Do ...
-
使用.htaccess重定向/投票到/vote.php?vote=1(Using .htaccess to redirect /vote to /vote.php?vote=1)[2022-02-08]
将此代码放在DOCUMENT_ROOT/.htaccess文件中: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^vote([0-9]+)/?$ /vote.php?vote=$1 [NC,QSA,L] Put this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On Rew ... -
尝试这个: select `fieldset_id`,`vote_type`,SUM(IF(`vote_type`='up',1,-1)) as `total_vote` from `vote_mst` GROUP BY `fieldset_id` Try this: select `fieldset_id`,`vote_type`,SUM(IF(`vote_type`='up',1,-1)) as `total_vote` from `vote_mst` GROUP BY `fieldset_i ...
-
用户的MySQL投票历史记录,每个项目的总投票数(MySQL vote history for user with total vote count for each item)[2021-01-11]
两件事情。 首先,尝试用HAVING MAX(CASE WHEN v.VOTER_ID = :id THEN 1 ELSE 0 END) = 1替换第二个查询中的HAVING子句。 其次,你的选择列表与你的小组不匹配,所以我不确定你在那里做什么。 确切的时间列是什么时候? 我想要的东西看起来像这样: SELECT COUNT(DISTINCT v.VOTE_ID) VOTECOUNT, n.ID, n.NAME FROM `votes` as v LEFT JOIN `names` as n ON n.ID ... -
投票系统使用双击(Vote system using double tap)[2022-03-07]
您应该将第一个onDoubleTap放在collectionView的cellForItemAtIndexPath并在那里进行配置。 You should place the first onDoubleTap in your collectionView's cellForItemAtIndexPath and configure it there.